code: def _replace_dropout_for_eval(m: torch.fx.GraphModule):
      """
      Replace the aten training dropout pattern with a noop, intended for eval.
  
      For models with dropout torch ops (nn.Dropout, F.dropout), calling model.eval()
      effectively turns these dropout ops into noops. For exported models, however,
      this is not done automatically, since the aten dropout patterns previously generated
      for training remain in the graph. Here we rewrite these dropout patterns with noops
      to avoid incorrectly applying further dropout during eval.
  
      See https://github.com/pytorch/pytorch/issues/103681.
      """
      # Avoid circular dependencies
      from .utils import get_aten_graph_module
  
      # Needed to ensure subgraph matches are self-contained
      m.graph.eliminate_dead_code()
      m.recompile()
  
      for inplace in [False, True]:
  
          def dropout_train(x):
              return F.dropout(x, p=0.5, training=True, inplace=inplace)
  
          def dropout_eval(x):
              return F.dropout(
                  x, p=0.5, training=False, inplace=inplace
              )
  
          example_inputs = (torch.randn(1),)
          match_pattern = get_aten_graph_module(
              dropout_train, example_inputs
          )
          replacement_pattern = get_aten_graph_module(
              dropout_eval, example_inputs
          )
  
          from torch.fx.subgraph_rewriter import (
              replace_pattern_with_filters,
          )
  
          replace_pattern_with_filters(
              m,
              match_pattern,
              replacement_pattern,
              match_filters=[],
              ignore_literals=True,
          )
          m.recompile()
  
imports: import torch
  import torch.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: _replace_dropout_for_eval(m) and returns: F, F