code: def _test_pattern_fails_with_tensor_factor(self):
      # https://github.com/pytorch/pytorch/issues/99124
      class Model(torch.nn.Module):
          def __init__(self, is_inv_factor):
              super().__init__()
              self.is_inv_factor = is_inv_factor
  
          def forward(
              self, query, key, value, scale_factor
          ) -> torch.Tensor:
              y = torch.matmul(query, key.transpose(-2, -1))
              if self.is_inv_factor:
                  y = y.div(scale_factor)
              else:
                  y = y.mul(scale_factor)
              return y.softmax(dim=-1).matmul(value)
  
      tensor_shape = (2, 4, 4, 4)
      for is_inv_factor in [True, False]:
          args = [
              torch.randn(tensor_shape, device=self.device),
              torch.randn(tensor_shape, device=self.device),
              torch.randn(tensor_shape, device=self.device),
              torch.randn((4, 1, 1), device=self.device),
          ]
          model = Model(is_inv_factor).eval()
          # The training path has an accuracy gap compared with eager mode.
          self._check_common(
              model,
              args1=args,
              contains=False,
              atol=1e-4,
              has_fuse_pattern=False,
          )
  
imports: import functools
  import itertools
  import math
  import torch
  import torch._inductor.config
  import torch.utils.checkpoint
  from torch._dynamo.test_case import run_tests, TestCase
  from torch._dynamo.utils import counters
  from torch._inductor.utils import run_and_get_code
  from torch.testing._internal.common_cuda import PLATFORM_SUPPORTS_FUSED_ATTENTION, SM80OrLater
  from torch.testing._internal.common_utils import IS_LINUX, skipIfRocm
  from torch.testing._internal.inductor_utils import HAS_CPU, HAS_CUDA
label_desc: Use image node_id 14 for calling the TestSDPAPatternRewriterTemplate obj's underlying member method code with example usage: obj._test_pattern_fails_with_tensor_factor() and returns: y