<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_cog(self, cog):
 """Adds a "cog" to the bot. A cog is a class that has its own event listeners and commands. Parameters cog: :class:`.Cog` The cog to register to the bot. Raises ------- TypeError The cog does not inherit from :class:`.Cog`. CommandError An error happened during loading. """


        if not isinstance(cog, Cog):
            raise TypeError('cogs must derive from Cog')

        cog = cog._inject(self)
        self.__cogs[cog.__cog_name__] = cog