class_docstr: Metaclass for `Module`.
class_docstr_tok: ["Metaclass","for","`","Module","`","."]
code: def __call__(cls: Type[T], *args, **kwargs) -> T:
      # Call new such that we have an un-initialized module instance that we can
      # still reference even if there is an exception during __init__. This is
      # needed such that we can make sure the name_scope constructed in __init__
      # is closed even if there is an exception.
  
      # NOTE: We disable pytype since (somewhat surprisingly) this method is bound
      # with the new class and not the metaclass.
      module = cls.__new__(
          cls, *args, **kwargs
      )  # pytype: disable=wrong-arg-types
  
      # Now attempt to initialize the object.
      try:
          module.__init__(*args, **kwargs)
      finally:
          exc_info = sys.exc_info()
  
          # The base Module constructor enters the modules name scope before
          # returning such that other functionality in the ctor happens within the
          # modules name scope.
          ctor_name_scope = getattr(module, "_ctor_name_scope", None)
          if ctor_name_scope is not None:
              ctor_name_scope.__exit__(*exc_info)
              del module._ctor_name_scope
  
          # TODO(tomhennigan) Remove `_scope_name` after next TF release.
          ran_super_ctor = hasattr(module, "_name_scope") or hasattr(
              module, "_scope_name"
          )
  
          if exc_info[0] is None and not ran_super_ctor:
              raise ValueError(
                  "Constructing a snt.Module without calling the super constructor "
                  "is not supported. Add the following as the first line in your "
                  "__init__ method:\n\nsuper(%s, self).__init__()"
                  % cls.__name__
              )
  
      module._auto_repr = auto_repr(
          cls, *args, **kwargs
      )  # pylint: disable=protected-access
  
      return module
  
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 2 for calling the ModuleMetaclass obj's underlying member method code with example usage: obj.__call__(cls) and returns: module