class_docstr: This class is used to automatically find problematic nodes in a model. It takes a FX
  graphmodule and generate some submodules while traverse the graph. Then two functions
  `run_a` and `run_b` will be used to run the same submodule and a function `compare_fn`
  will be used to compare the results.
  
  Currently we provides two ways to traverse the graph and generate submodules.
      1. Sequential traversal: this will traverse the graph node by node and generate
         one submodule with one sigle node.
      2. Binary searching: this will do a binary search style traversal on the graph.
  
  For internal Users, a guide can be found here https://fb.quip.com/HDtuAgiKGfkP.
docstr: Run the submodule in `split_module` that has name `submod_name`
  using `self.run_a` and `self.run_b` and compare their results.
  
  Args:
      split_module: Main module that contains the minimize submodule.
      submod_name: Name of the minimize submodule.
      output_names: Names of the node we want to output. If None, we
          will use the original output.
code: def _run_and_compare(
      self,
      split_module: torch.fx.GraphModule,
      submod_name: str,
      output_names: Names,
  ):
      """
      Run the submodule in `split_module` that has name `submod_name`
      using `self.run_a` and `self.run_b` and compare their results.
  
      Args:
          split_module: Main module that contains the minimize submodule.
          submod_name: Name of the minimize submodule.
          output_names: Names of the node we want to output. If None, we
              will use the original output.
      """
      submodule = getattr(split_module, submod_name)
      a_input, b_input = self._get_submod_inputs(
          split_module, submod_name
      )
  
      if len(self.reports) == 0:
          self.reports.append([])
          self.iteration = 1
  
      report = self.reports[self.iteration - 1]
      report.append("Run and compare ...")
  
      if output_names:
          output_nodes: NodeList = []
          for node in submodule.graph.nodes:
              if node.op == "output":
                  submodule.graph.erase_node(node)
  
              if node.name in output_names:
                  output_nodes.append(node)
  
          submodule.graph.output(
              output_nodes[0]
              if len(output_nodes) == 1
              else tuple(output_nodes)
          )
          submodule.graph.lint()
          submodule.recompile()
  
      # Use name of args in output node as key to store comparison result
      for node in submodule.graph.nodes:
          if node.op == "output":
              result_key = map_arg(node.args, lambda x: x.name)
  
      try:
          a_result = self.run_a(submodule, a_input)
          b_result = self.run_b(submodule, b_input)
          self._store_outputs(a_result, b_result, submodule)
      except Exception as e:
          report.append(
              f"Exception raised when running {submod_name}: {e}"
          )
          raise FxNetMinimizerRunFuncError(  # noqa: TRY200
              f"Exception raised when running {submod_name}: {e}"
          )
  
      # Compare results
      names: Names = output_names
      if output_names is None:
          names = [str(v) for v in result_key]
  
      numeric_result, bool_result = self.compare_fn(
          a_result, b_result, names
      )
  
      self.results[result_key] = numeric_result
      report.append(f"Numerical accuracy = {numeric_result}")
      if not bool_result:
          report.append(f"Result mismatch for {result_key}")
          if self.module_exporter:
              self.module_exporter(
                  List[torch.Tensor](a_input),
                  submodule,
                  str(result_key[0]) + "_cpu",
              )
              self.module_exporter(
                  List[torch.Tensor](b_input),
                  submodule,
                  str(result_key[0]) + "_acc",
              )
          raise FxNetMinimizerResultMismatchError(
              f"Result mismatch for {result_key}"
          )
  
imports: import logging
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  import torch.fx
  from torch.fx._compatibility import compatibility
  from torch.fx.node import map_arg
  from .shape_prop import ShapeProp
  from .split_utils import split_by_tags
  from .tools_common import CALLABLE_NODE_OPS, FxNetAccFusionsFinder, Names, NodeList, NodeSet, TensorOrTensors, Tensors
label_desc: Use image node_id 8 for calling the _MinimizerBase obj's underlying member method code with example usage: obj._run_and_compare(split_module, submod_name, output_names) without return types