<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_global(self, cache_namespace: str = None) -> type: """ Decorator. Attaches the global key-value store of this hierarchy to an object. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of the class this is applied to and the ``attribute_name`` of this ``Hierarkey`` object. """


        if isinstance(cache_namespace, type):
            raise ImproperlyConfigured('Incorrect decorator usage, you need to use .add_global() '
                                       'instead of .add_global')

        def wrapper(wrapped_class):
            if issubclass(wrapped_class, models.Model):
                raise ImproperlyConfigured('Hierarkey.add_global() can only be invoked on a normal class, '
                                           'not on a Django model.')
            if not issubclass(wrapped_class, GlobalSettingsBase):
                raise ImproperlyConfigured('You should use .add_global() on a class that inherits from '
                                           'GlobalSettingsBase.')

            _cache_namespace = cache_namespace or ('%s_%s' % (wrapped_class.__name__, self.attribute_name))

            attrs = self._create_attrs(wrapped_class)

            model_name = '%s_%sStore' % (wrapped_class.__name__, self.attribute_name.title())
            if getattr(sys.modules[wrapped_class.__module__], model_name, None):
                # Already wrapped
                return wrapped_class

            kv_model = self._create_model(model_name, attrs)

            def init(self, *args, object=None, **kwargs):
                super(kv_model, self).__init__(*args, **kwargs)

            setattr(kv_model, '__init__', init)

            hierarkey = self

            def prop(iself):
                from .proxy import HierarkeyProxy

                attrname = '_hierarkey_proxy_{}_{}'.format(_cache_namespace, self.attribute_name)
                cached = getattr(iself, attrname, None)
                if not cached:
                    cached = HierarkeyProxy._new(iself, type=kv_model, hierarkey=hierarkey,
                                                 cache_namespace=_cache_namespace)
                    setattr(iself, attrname, cached)
                return cached

            setattr(sys.modules[wrapped_class.__module__], model_name, kv_model)
            setattr(wrapped_class, '_%s_objects' % self.attribute_name, kv_model.objects)
            setattr(wrapped_class, self.attribute_name, property(prop))
            self.global_class = wrapped_class
            return wrapped_class

        return wrapper