parameters: (self, mode: bool = True, recursive: bool = True)
docstring: r"""Sets training mode of all the modules within this module (including itself) to
          ``mode``. This effectively sets the ``training`` attributes of those modules
          to ``mode``, but only has effect on certain modules (e.g.
          :class:`~.BatchNorm2d`, :class:`~.Dropout`, :class:`~.Observer`)
  
          Args:
              mode: the training mode to be set on modules.
              recursive: whether to recursively call submodules' ``train()``.
docstring_summary: r"""Sets training mode of all the modules within this module (including itself) to
          ``mode``. This effectively sets the ``training`` attributes of those modules
          to ``mode``, but only has effect on certain modules (e.g.
          :class:`~.BatchNorm2d`, :class:`~.Dropout`, :class:`~.Observer`)
docstring_tokens: r Sets training mode of all the modules within this module ( including itself ) to mode . This effectively sets the training attributes of those modules to mode but only has effect on certain modules ( e . g . : class : ~ . BatchNorm2d : class : ~ . Dropout : class : ~ . Observer )
function: def train(self, mode: bool = True, recursive: bool = True) -> None:
          r"""Sets training mode of all the modules within this module (including itself) to
          ``mode``. This effectively sets the ``training`` attributes of those modules
          to ``mode``, but only has effect on certain modules (e.g.
          :class:`~.BatchNorm2d`, :class:`~.Dropout`, :class:`~.Observer`)
  
          Args:
              mode: the training mode to be set on modules.
              recursive: whether to recursively call submodules' ``train()``.
          """
          if not recursive:
              self.training = mode
              return
  
          def fn(module: Module) -> None:
              module.train(mode, recursive=False)
  
          self.apply(fn)
function_tokens: def train ( self , mode : bool = True , recursive : bool = True ) -> None : if not recursive : self . training = mode return def fn ( module : Module ) -> None : module . train ( mode , recursive = False ) self . apply ( fn )