code: def eval_mode(*nets: nn.Module):
      """
      Set network(s) to eval mode and then return to original state at the end.
  
      Args:
          nets: Input network(s)
  
      Examples
  
      .. code-block:: python
  
          t=torch.rand(1,1,16,16)
          p=torch.nn.Conv2d(1,1,3)
          print(p.training)  # True
          with eval_mode(p):
              print(p.training)  # False
              print(p(t).sum().backward())  # will correctly raise an exception as gradients are calculated
      """
  
      # Get original state of network(s).
      # Check the training attribute in case it's TensorRT based models which don't have this attribute.
      training = [
          n for n in nets if hasattr(n, "training") and n.training
      ]
  
      try:
          # set to eval mode
          with torch.no_grad():
              yield [
                  n.eval() if hasattr(n, "eval") else n for n in nets
              ]
      finally:
          # Return required networks to training
          for n in training:
              if hasattr(n, "train"):
                  n.train()
  
imports: from __future__ import annotations
  import io
  import re
  import warnings
  from collections import OrderedDict
  from collections.abc import Callable, Mapping, Sequence
  from contextlib import contextmanager
  from copy import deepcopy
  from typing import Any
  import numpy
  import torch
  import torch.nn
  from monai.apps.utils import get_logger
  from monai.config import PathLike
  from monai.utils.misc import ensure_tuple, save_obj, set_determinism
  from monai.utils.module import look_up_option, optional_import, pytorch_after
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 11 for calling a global function with example usage: eval_mode() without return types