code: def _get_existing_inline_assertions(
      graph_module: torch.fx.GraphModule,
      range_constraints: Dict[sympy.Symbol, ValueRanges],
  ) -> Dict[sympy.Symbol, ValueRanges]:
      existing_inline_assertions: Dict[sympy.Symbol, ValueRanges] = {}
  
      for module in graph_module.modules():
          if not isinstance(module, torch.fx.GraphModule):
              continue
  
          # Find all the existing inline assertions. They will look something like:
          # %_local_scalar_dense = call_function[target=torch.ops.aten._local_scalar_dense.default](args = (%arg1_1,), kwargs = {})
          # %ge = call_function[target=operator.ge](args = (%_local_scalar_dense, 0), kwargs = {})
          # %scalar_tensor = call_function[target=torch.ops.aten.scalar_tensor.default](args = (%ge,), kwargs = {})
          # %_assert_async = call_function[target=torch.ops.aten._assert_async.msg](args = (%scalar_tensor, "..."), kwargs = {})
          for node in module.graph.nodes:
              if node.target != torch.ops.aten._assert_async.msg:
                  continue
  
              scalar_tensor_arg = node.args[0]
              if not (
                  scalar_tensor_arg.op == "call_function"
                  and scalar_tensor_arg.target
                  == torch.ops.aten.scalar_tensor.default
              ):
                  continue
  
              compare_arg = scalar_tensor_arg.args[0]
              if not (
                  compare_arg.op == "call_function"
                  and compare_arg.target in (operator.le, operator.ge)
                  and len(compare_arg.args) == 2
              ):
                  continue
  
              compare_op = compare_arg.target
              maybe_symint_arg, compare_int = compare_arg.args
  
              # x >= 0 will sometimes be canonicalized to -x <= 0, so in some
              # cases the operation before the comparison is to multiply by -1. We
              # can undo the canonicalization here
              if (
                  maybe_symint_arg.op == "call_function"
                  and maybe_symint_arg.target == operator.mul
                  and maybe_symint_arg.args[0] == -1
              ):
                  maybe_symint_arg = maybe_symint_arg.args[1]
                  compare_op = operator.ge
                  compare_int = -1 * compare_int
  
              if not (
                  "val" in maybe_symint_arg.meta
                  and isinstance(
                      maybe_symint_arg.meta["val"], torch.SymInt
                  )
              ):
                  continue
  
              symint = maybe_symint_arg.meta["val"].node._expr
              if not isinstance(symint, sympy.Symbol):
                  continue
  
              if symint not in range_constraints:
                  raise RuntimeError(
                      f"Unable to find symint {symint} in {range_constraints}"
                  )
  
              found_range = existing_inline_assertions.get(
                  symint, ValueRanges(-math.inf, math.inf)
              )
  
              if compare_arg.target == operator.le:
                  existing_inline_assertions[symint] = ValueRanges(
                      lower=found_range.lower, upper=compare_int
                  )
              elif compare_arg.target == operator.ge:
                  existing_inline_assertions[symint] = ValueRanges(
                      lower=compare_int, upper=found_range.upper
                  )
  
      return existing_inline_assertions
  
imports: import math
  import operator
  import traceback
  from functools import partial
  from typing import Callable, Dict, List, NamedTuple, Set
  import sympy
  import torch
  import torch.fx
  from torch._export.pass_base import _ExportPassBaseDeprecatedDoNotUse, ProxyValue, PassResult
  from torch.utils._sympy.value_ranges import ValueRanges
label_desc: Use image node_id 3 for calling a global function with example usage: _get_existing_inline_assertions(graph_module, range_constraints) and returns: existing_inline_assertions