code: def freezing_passes(gm: torch.fx.GraphModule, aot_example_inputs):
      """
      Passes that are applied to the graph to freeze pass.
      """
  
      from ..freezing import constant_fold
  
      lazy_init()
      # We need a few rounds of binary folding to get rid of all the
      # unnecessary nodes, but may need a good method to chose the rounds number.
      # works like: conv+binary+binary.
      binary_folding = counters["inductor"]["binary_folding"]
      fake_tensor_prop(gm, aot_example_inputs, True)
  
      torch._inductor.fx_passes.binary_folding.mark_mixed_dtype_allowed_convs(
          gm
      )
      for _ in range(4):
          constant_fold(gm)
          # Make sure meta['val'] is properly set for all nodes
          fake_tensor_prop(gm, aot_example_inputs, True)
          binary_folding_pass.apply(gm.graph)
          # If we don't have binary folding, we don't need to run the pass again.
          # TODO: remove the need to run fake_tensor_prop on the whole model.
          if counters["inductor"]["binary_folding"] == binary_folding:
              break
          binary_folding = counters["inductor"]["binary_folding"]
  
      torch._inductor.fx_passes.binary_folding.recover_original_precision_folded_convs(
          gm
      )
  
      constant_fold(gm)
      fake_tensor_prop(gm, aot_example_inputs, True)
  
      for pattern in pass_patterns:
          pattern.apply(gm.graph)
  
      # The CPU weight packing always assume the conv's weight is channels last,
      # So make sure the layout_optimization is on when doing it.
      if (
          torch._C._has_mkldnn
          and config.cpp.weight_prepack
          and config.layout_optimization
      ):
          from .mkldnn_fusion import _eliminate_duplicate_packed_nodes
  
          _eliminate_duplicate_packed_nodes(gm)
  
      stable_topological_sort(gm.graph)
      gm.recompile()
      gm.graph.lint()
  
file_path: pytorch/torch/_inductor/fx_passes/freezing_patterns.py
imports: import functools
  import torch
  from torch._inductor.compile_fx import fake_tensor_prop
  from ..._dynamo.utils import counters
  from ..None import config
  from ..pattern_matcher import _return_true, CallFunction, fwd_only, Ignored, init_once_fakemode, KeywordArg, Match, PatternMatcherPass, register_graph_pattern, register_replacement, stable_topological_sort
label_desc: Use image node_id 1 for calling a global function with example usage: freezing_passes(gm, aot_example_inputs) without return types