code: def run_repro(
      mod,
      load_args,
      *,
      command="run",
      accuracy: Union[bool, str] = "",
      save_dir=None,
      tracing_mode=None,
      patch_code=None,
      check_str=None,
      **kwargs,
  ):
      for k in kwargs:
          log.warning(
              "Unrecognized kwarg %s; perhaps this repro was made on a newer version of PyTorch",
              k,
          )
  
      if accuracy is True:
          accuracy = "accuracy"
      elif accuracy is False:
          accuracy = ""
  
      if patch_code is not None:
          log.warning(
              "patch_code no longer works on this version of PyTorch, silently ignoring"
          )
  
      parser = argparse.ArgumentParser(
          description=f"""\
  An after_aot repro script, typically triggering a bug in PyTorch Inductor.
  When run with no arguments, this script defaults to running '{command}'.
  Extra flags may be available; to find out more, try '{command} --help'.
  There are also alternate subcommands available, see below.
  
  default settings on this script:
    {accuracy=}
    {tracing_mode=}
    {save_dir=}
    {check_str=}
  """,
          formatter_class=argparse.RawTextHelpFormatter,
      )
  
      def common_flags(parser):
          accuracy_group = parser.add_mutually_exclusive_group()
          accuracy_group.add_argument(
              "--no-accuracy",
              dest="accuracy",
              action="store_const",
              const="",
              default=accuracy,
              help="do not test accuracy, just run the module and see if it errors",
          )
          accuracy_group.add_argument(
              "--accuracy",
              action="store_const",
              const="accuracy",
              default=accuracy,
              help="""\
  test if the RMSE between the compiled module and the fp64 reference is greater
  than eager and the fp64 reference. This is usually more reliable than the
  standard allclose test, as we expect numeric differences from compiling, often
  improving accuracy over eager.  RMSE test allows for compiled module to
  diverge greatly from eager, as long as this divergence moves it closer to the
  'true' mathematical value of the network.  Caveats: (1) double precision can
  still suffer from rounding error, so it is not a perfect reference (see for
  example 'Herbie: Automatically Improving Floating Point Accuracy') for
  approaches that detect the necessary working precision and compute it in
  arbitrary precision floating point; unfortunately, this is not practical for
  tensor computation; (2) if there are not enough samples in the output being
  compared, we may get unlucky and have an unlucky greater RMSE than eager; this
  could be overcome by applying a more rigorous statistical test at some
  p-value, which we leave for future work.
  """,
          )
          accuracy_group.add_argument(
              "--strict-accuracy",
              dest="accuracy",
              action="store_const",
              const="strict_accuracy",
              default=accuracy,
              help="""\
  by default, when doing accuracy minification we will reject reductions which
  change the divergence from a floating point divergence to a integral/boolean
  divergence.  This is because some operations like ReLU involve temporarily
  sharp boundaries that smooth out again afterwards; without requiring
  divergence on floating point, the minifier will often fixate on divergent
  boolean tensor even though this is not the true source of the divergence.
  However, rejecting these reductions makes it more difficult for the minifier
  to make process.  Using this option will let the minifier progress for ALL
  divergences--you just might not end up with a useful repro in the end.""",
          )
  
          parser.add_argument(
              "--save-dir",
              type=str,
              default=save_dir,
              metavar="DIR",
              help="directory where saved inputs live",
          )
          parser.add_argument(
              "--no-save-dir",
              dest="save_dir",
              action="store_const",
              const=None,
              help="don't use any directory for saved inputs",
          )
          parser.add_argument(
              "--tracing-mode",
              type=str,
              metavar="{real,fake,symbolic}",
              default=tracing_mode,
              help="how to trace the repro module into a GraphModule with metadata",
          )
  
      subparsers = parser.add_subparsers(
          dest="command", metavar="{run,minify,analyze}", required=True
      )
  
      parser_run = subparsers.add_parser(
          "run",
          help="just run the repro",
      )
      common_flags(parser_run)
  
      parser_minify = subparsers.add_parser(
          "minify", help="run the minifier on the repro"
      )
      common_flags(parser_minify)
      parser_minify_isolate = (
          parser_minify.add_mutually_exclusive_group()
      )
      parser_minify_isolate.add_argument(
          "--isolate",
          action="store_true",
          default=True,
          help="run in separate processes to avoid interference (default)",
      )
      parser_minify_isolate.add_argument(
          "--no-isolate",
          dest="isolate",
          action="store_false",
          help="speed up by running all compilation in same process",
      )
      parser_minify.add_argument(
          "--skip-saving-eager-intermediates",
          action="store_true",
          help="skip saving eager intermediates on --minify",
      )
      # TODO: make this an option for --analyze too
      parser_minify.add_argument(
          "--offload-to-disk",
          action="store_true",
          help="during minification, offload delta debugging intermediates to disk.  Use if you're OOMing",
      )
      parser_minify.add_argument(
          "--skip-sanity",
          action="store_true",
          help="skip sanity check at beginning of minification on original graph",
      )
      parser_minify.add_argument(
          "--max-granularity",
          type=int,
          default=None,
          help="start at this granularity and work down; must be power of 2",
      )
      parser_minify.add_argument(
          "--check-str",
          type=str,
          default=check_str,
          help="require minified program to fail with error containing this string",
      )
  
      parser_analyze = subparsers.add_parser(
          "analyze", help="run the accuracy analyzer on the repro"
      )
      common_flags(parser_analyze)
      parser_analyze.add_argument(
          "--skip-saving-inductor-intermediates",
          action="store_true",
          help="skip saving inductor intermediates on --analyze",
      )
      parser_analyze.add_argument(
          "--skip-saving-float64-intermediates",
          action="store_true",
          help="skip saving float64 intermediates",
      )
      parser_analyze.add_argument(
          "--skip-check-deterministic",
          action="store_true",
          help="skip checking that the network is deterministic",
      )
      parser_analyze.add_argument(
          "--stable-hash",
          action="store_true",
          help="use SHA-1 checksum instead of fast (but possibly unsound) hash",
      )
  
      # Run the repro in the context of minification, inverting exit code meaning
      parser_minifier_query = subparsers.add_parser(
          "minifier-query",
      )
      common_flags(parser_minifier_query)
      parser_minifier_query.add_argument(
          "--check-str",
          type=str,
          default=check_str,
          help="require minified program to fail with error containing this string",
      )
  
      args = None
      if len(sys.argv) <= 1:
          args = [command, *sys.argv[1:]]
  
      options = parser.parse_args(args)
      COMMAND_FNS = {
          "minify": repro_minify,
          "analyze": repro_analyze,
          "minifier-query": repro_minifier_query,
          "run": repro_run,
      }
      COMMAND_FNS[options.command](options, mod, load_args)
  
imports: import argparse
  import copy
  import functools
  import io
  import logging
  import os
  import shutil
  import subprocess
  import sys
  import textwrap
  import uuid
  from importlib import import_module
  from tempfile import TemporaryFile
  from typing import Any, Callable, Dict, Union
  import torch
  import torch.fx
  import torch.nn
  from torch._dynamo.debug_utils import _cuda_system_info_comment, AccuracyError, backend_accuracy_fails, BuckTargetWriter, cast_to_fp64, extra_imports, generate_config_string, helper_for_dump_minify, InputReader, InputWriter, MAX_CONSTANT_NUMEL_INLINE, minifier_dir, NNModuleToString, NopInputReader, same_two_models
  from torch._dynamo.utils import clone_inputs, counters, same
  from torch.fx.experimental.proxy_tensor import make_fx
  from torch.fx.experimental.symbolic_shapes import fx_placeholder_targets, has_free_symbols
  from torch.hub import tqdm
  from ..None import config
label_desc: Use image node_id 14 for calling a global function with example usage: run_repro(mod, load_args) without return types