<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_plugin(self, plugin: Plugin):
 """ Register a plugin. """

        if isinstance(plugin, Plugin):
            lazy = False
        elif issubclass(plugin, Plugin):
            lazy = True
        else:
            msg = 'plugin %r must be an object/class of type Plugin' % plugin
            raise DiayException(msg)

        predicate = inspect.isfunction if lazy else inspect.ismethod
        methods = inspect.getmembers(plugin, predicate=predicate)
        for _, method in methods:
            if getattr(method, '__di__', {}).get('provides'):
                if lazy:
                    self.register_lazy_provider_method(plugin, method)
                else:
                    self.register_provider(method)