class_docstr: A derivative of `fx.GraphModule`. Differs in the following ways:
  - Requires a train and eval version of the underlying graph
  - Copies submodules according to the nodes of both train and eval graphs.
  - Calling train(mode) switches between train graph and eval graph.
docstr: Swap out the graph depending on the selected training mode.
  NOTE this should be safe when calling model.eval() because that just
  calls this with mode == False.
docstr_tok: ["Swap","out","the","graph","depending","on","the","selected","training","mode",".","NOTE","this","should","be","safe","when","calling","model.eval","(",")","because","that","just","calls","this","with","mode","==","False","."]
code: def train(self, mode=True):
      """
      Swap out the graph depending on the selected training mode.
      NOTE this should be safe when calling model.eval() because that just
      calls this with mode == False.
      """
      # NOTE: Only set self.graph if the current graph is not the desired
      # one. This saves us from recompiling the graph where not necessary.
      if mode and not self.training:
          self.graph = self.train_graph
      elif not mode and self.training:
          self.graph = self.eval_graph
      return super().train(mode=mode)
  
imports: import inspect
  import math
  import re
  import warnings
  from collections import OrderedDict
  from copy import deepcopy
  from itertools import chain
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  import torchvision
  from torch import fx, nn
  from torch.fx.graph_module import _copy_attr
label_desc: Use image node_id 2 for calling the DualGraphModule obj's underlying member method code with example usage: obj.train(mode) and returns: super