docstr: A context manager to temporarily set the training mode of 'model'
  to 'mode', resetting it when we exit the with-block.  A no-op if
  mode is None.
code: def set_training(self, model, mode):
      r"""
      A context manager to temporarily set the training mode of 'model'
      to 'mode', resetting it when we exit the with-block.  A no-op if
      mode is None.
      """
      if mode is None:
          yield
          return
      old_mode = model.training
      if old_mode != mode:
          model.train(mode)
      try:
          yield
      finally:
          if old_mode != mode:
              model.train(old_mode)
  
imports: from mmdnn.conversion.common.DataStructure.graph import GraphNode, Graph
  import torch
  import torch.autograd
  import torch.serialization
  import contextlib
  from torch.jit import _unique_state_dict
label_desc: Use image node_id 7 for calling the PytorchGraph040 obj's underlying member method code with example usage: obj.set_training(model, mode) without return types