<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tier(self, *args, append=True, source=None, **kwargs):
 """ Function decorator for a tier coroutine. If the function being decorated is not already a coroutine function it will be wrapped. """

        if len(args) == 1 and not kwargs and callable(args[0]):
            raise TypeError('Uncalled decorator syntax is invalid')

        def decorator(coro):
            if not asyncio.iscoroutinefunction(coro):
                coro = asyncio.coroutine(coro)
            if append and source is None:
                self.append_tier(coro, *args, **kwargs)
            else:
                self.add_tier(coro, *args, source=source, **kwargs)
            return coro
        return decorator