docstr: Test caching the same graph, but under conditions that introduce guards
  for static bounds.
docstr_tok: ["Test","caching","the","same","graph",",","but","under","conditions","that","introduce","guards","for","static","bounds","."]
code: def test_cache_load_with_guards_static_bounds(self, device, dtype):
      """
      Test caching the same graph, but under conditions that introduce guards
      for static bounds.
      """
      if device == "cuda" and not HAS_CUDA:
          raise unittest.SkipTest("requires CUDA")
      if (
          device == "cuda"
          and dtype == torch.bfloat16
          and not SM80OrLater
      ):
          raise unittest.SkipTest("requires SM80 or later")
  
      # See lowering; for all of the pooling operators, we always guard and
      # make the height/width static.
      def fn(x):
          return torch.nn.functional.adaptive_avg_pool2d(x, [5, 7])
  
      compiled_fn = torch.compile(fn, dynamic=True)
  
      # Iterate over different input shapes. Each new shape should cause
      # a cache miss.
      shapes = ((1, 64, 8, 9), (1, 64, 9, 10), (1, 64, 10, 11))
      for shape in shapes:
          x = torch.rand(shape, device=device, dtype=dtype)
  
          # AVOID a dynamo reset here. For each cache hit, we expect guards
          # to have been added that will be violated with each new shape.
          # We should see a recompilation (along with a cache miss).
          counters.clear()
          res1 = compiled_fn(x)
          self.assertGreater(
              counters["inductor"]["fxgraph_cache_miss"], 0
          )
          self.assertEqual(counters["inductor"]["fxgraph_cache_hit"], 0)
  
          # A second call should hit.
          counters.clear()
          torch._dynamo.reset()
          res2 = compiled_fn(x)
          self.assertEqual(
              counters["inductor"]["fxgraph_cache_miss"], 0
          )
          self.assertGreater(
              counters["inductor"]["fxgraph_cache_hit"], 0
          )
  
          self.assertEqual(res1, res2)
  
imports: import functools
  import pickle
  import tempfile
  import unittest
  from unittest.mock import patch
  import torch
  from torch._dynamo.test_case import run_tests, TestCase
  from torch._dynamo.utils import counters
  from torch._inductor import config
  from torch._inductor.codecache import AsyncCompile, FxGraphCachePickler, FxGraphHashDetails, TensorMetadata, TensorMetadataAndValues
  from torch.testing._internal.common_cuda import SM80OrLater
  from torch.testing._internal.common_device_type import largeTensorTest
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize
  from torch.testing._internal.inductor_utils import HAS_CUDA
  from torch.utils._triton import has_triton
label_desc: Use image node_id 7 for calling the TestFxGraphCache obj's underlying member method code with example usage: obj.test_cache_load_with_guards_static_bounds(device, dtype) and returns: torch