class_docstr: Metaclass for `Module`.
class_docstr_tok: ["Metaclass","for","`","Module","`","."]
code: def __new__(
      cls: Type[Type[T]],
      name: str,
      bases: Tuple[Type[Any], ...],
      clsdict: Dict[str, Any],
  ) -> Type[T]:
      methods = []
  
      for key, value in clsdict.items():
          if key == "name_scope":
              continue
  
          elif key.startswith("__") and key != "__call__":
              # Don't patch methods like `__getattr__` or `__del__`.
              continue
  
          elif isinstance(value, property):
              # TODO(tomhennigan) Preserve the type of property subclasses.
              clsdict[key] = property(
                  value.fget
                  if not value.fget
                  else with_name_scope(value.fget),
                  value.fset
                  if not value.fset
                  else with_name_scope(value.fset),
                  value.fdel
                  if not value.fdel
                  else with_name_scope(value.fdel),
                  doc=value.__doc__,
              )
  
          elif inspect.isfunction(value) or isinstance(
              value, TFFunctionType
          ):
              # We defer patching methods until after the type is created such that we
              # can trigger the descriptor binding them to the class.
              methods.append(key)
  
      clsdict.setdefault(
          "__repr__", lambda module: module._auto_repr
      )  # pylint: disable=protected-access
  
      new_cls = super(ModuleMetaclass, cls).__new__(
          cls, name, bases, clsdict
      )  # pylint: disable=too-many-function-args
  
      for method_name in methods:
          # Note: the below is quite subtle, we need to ensure that we're wrapping
          # the method bound to the class. In some cases (e.g. `wrapt`) this is
          # important since the method can trigger different behavior when it is
          # bound (e.g. in wrapt `FunctionWrapper.__get__(None, cls)` produces a
          # `BoundFunctionWrapper` which in turn populates the `instance` argument
          # to decorator functions using args[0]).
          # Equivalent to: `cls.__dict__[method_name].__get__(None, cls)`
          method = getattr(new_cls, method_name)
          method = with_name_scope(method)
          setattr(new_cls, method_name, method)
  
      return new_cls
  
imports: import abc
  import functools
  import inspect
  import os
  import pprint
  import sys
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, TypeVar
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 1 for calling the ModuleMetaclass obj's underlying member method code with example usage: obj.__new__(cls, name, bases, clsdict) and returns: new_cls