code: def test_fuse_attention_roundtrip_pattern(self):
      # are we losing anything in serialization
      from torch._inductor.fx_passes.fuse_attention import (
          _get_sfdp_patterns,
      )
  
      global_vals = {
          "aten": torch.ops.aten,
          "prims": torch.ops.prims,
          "torch": torch,
      }
  
      for name in dir(torch._inductor.pattern_matcher):
          attr = getattr(torch._inductor.pattern_matcher, name)
          if isinstance(attr, type) and issubclass(
              attr, (PatternExpr, _TargetExpr)
          ):
              global_vals[name] = attr
  
      with torch._subclasses.FakeTensorMode():
          for _, kwargs in _get_sfdp_patterns():
              gen_kwargs = {
                  key: kwargs[key]
                  for key in (
                      "search_fn",
                      "example_inputs",
                      "trace_fn",
                      "scalar_workaround",
                  )
              }
              pattern = gen_pattern(**gen_kwargs)
              pattern_pp = PatternPrettyPrinter.run(pattern)
              env = global_vals.copy()
              exec(pattern_pp, env)
              pattern_2 = env["output"]
              self.assertEqual(
                  pattern_pp, PatternPrettyPrinter.run(pattern_2)
              )
  
imports: import copy
  import unittest
  import torch
  import torch._dynamo.config
  import torch._inductor.config
  from torch._dynamo.test_case import run_tests, TestCase
  from torch._dynamo.utils import count_calls, counters
  from torch._higher_order_ops.out_dtype import out_dtype
  from torch._inductor.fx_passes import joint_graph
  from torch._inductor.fx_passes.serialized_patterns.central_index import get_serialized_pattern
  from torch._inductor.pattern_matcher import _TargetExpr, Arg, CallFunction, gen_pattern, KeywordArg, Match, PatternExpr, PatternMatcherPass, PatternPrettyPrinter, register_graph_pattern, stable_topological_sort
  from torch._inductor.utils import run_and_get_code
  from torch._inductor.virtualized import V
  from torch.testing import FileCheck
  from torch.testing._internal.common_cuda import SM80OrLater
  from torch.testing._internal.common_utils import IS_LINUX, skipIfRocm
  from torch.testing._internal.inductor_utils import HAS_CUDA
label_desc: Use image node_id 30 for calling the TestPatternMatcher obj's underlying member method code with example usage: obj.test_fuse_attention_roundtrip_pattern() without return types