def declared_metaclass(self, context=None):
for base in self.bases:<EOL><INDENT>try:<EOL><INDENT>for baseobj in base.infer(context=context):<EOL><INDENT>if isinstance(baseobj, ClassDef) and baseobj.hide:<EOL><INDENT>self._metaclass = baseobj._metaclass<EOL>self._metaclass_hack = True<EOL>break<EOL><DEDENT><DEDENT><DEDENT>except exceptions.InferenceError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if self._metaclass:<EOL><INDENT>try:<EOL><INDENT>return next(<EOL>node<EOL>for node in self._metaclass.infer(context=context)<EOL>if node is not util.Uninferable<EOL>)<EOL><DEDENT>except (exceptions.InferenceError, StopIteration):<EOL><INDENT>return None<EOL><DEDENT><DEDENT>return None<EOL>
Return the explicit declared metaclass for the current class.

        An explicit declared metaclass is defined
        either by passing the ``metaclass`` keyword argument
        in the class definition line (Python 3) or (Python 2) by
        having a ``__metaclass__`` class attribute, or if there are
        no explicit bases but there is a global ``__metaclass__`` variable.

        :returns: The metaclass of this class,
            or None if one could not be found.
        :rtype: NodeNG or None