code: def cublas_addmm(
      self,
      size: int,
      dtype: torch.dtype,
      reduced_precision: bool = False,
  ):
      #
      # Check for catastrophic cuBLAS inaccuracy by measuring the deviation between
      # results from the CUDA invocation of torch.addmm and the CPU invocation
      # (which does not use CUDA backend).
      #
      # Get dims
      n, m, p = (size + 1, size, size + 2)
      # Disable reduced precision reductions in BFloat16 to bypass some kernels
      # which fail the threshold check
      orig_bf16 = (
          torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction
      )
      orig_fp16 = (
          torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction
      )
      torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = (
          reduced_precision
      )
      torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = (
          reduced_precision
      )
      # Make random tensors on CPU (seed set on common_utils.py import)
      # (Not using numpy because it does not support bfloat16)
      make_arg = partial(make_tensor, dtype=dtype, device="cpu")
      m_beta = make_arg(1)
      m_input = make_arg((n, p))
      m_1 = make_arg((n, m))
      m_2 = make_arg((m, p))
      # *(B)FLOAT16 Special Handling*
      # Backend does not tensorize float16 on CPU,
      # and bloat16 may present accuracy issues,
      # so convert to float32 for these cases
      # (but keep same for other types, e.g. float32 and int*)
      if dtype == torch.float16 or dtype == torch.bfloat16:
          m_beta = m_beta.to(dtype=torch.float32)
          m_input = m_input.to(dtype=torch.float32)
          m_1 = m_1.to(dtype=torch.float32)
          m_2 = m_2.to(dtype=torch.float32)
      # Get CPU result
      res_cpu = torch.addmm(m_input, m_1, m_2, beta=m_beta.item())
      # *(B)FLOAT16 Special Handling*``
      # Convert back to (b)float16
      if dtype == torch.float16 or dtype == torch.bfloat16:
          m_beta = m_beta.to(dtype=dtype)
          m_input = m_input.to(dtype=dtype)
          m_1 = m_1.to(dtype=dtype)
          m_2 = m_2.to(dtype=dtype)
          res_cpu = res_cpu.to(dtype=dtype)
      # Move arg tensors to CUDA
      m_beta = m_beta.to("cuda")
      m_input = m_input.to("cuda")
      m_1 = m_1.to("cuda")
      m_2 = m_2.to("cuda")
      # Get CUDA result
      res_cuda = torch.addmm(m_input, m_1, m_2, beta=m_beta.item())
      # Move to CPU for comparison
      res_cuda = res_cuda.to("cpu")
      # Compare
      self.assertEqual(res_cpu, res_cuda)
      torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = (
          orig_bf16
      )
      torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = (
          orig_fp16
      )
  
imports: import unittest
  from itertools import product
  from functools import partial
  from typing import Optional
  import torch
  from torch.quantization._quantized_conversions import pack_int4_to_int8, quantized_weight_reorder_for_mixed_dtypes_linear_cutlass
  from torch.testing import make_tensor
  from torch.testing._internal.common_cuda import SM53OrLater, _get_torch_cuda_version
  from torch.testing._internal.common_device_type import dtypes, instantiate_device_type_tests, onlyCUDA, tol, toleranceOverride
  from torch.testing._internal.common_utils import IS_ARM64, IS_JETSON, IS_WINDOWS, parametrize, run_tests, skipIfRocmVersionLessThan, TEST_WITH_ROCM, skipIfRocm, TestCase
label_desc: Use image node_id 3 for calling the TestMatmulCuda obj's underlying member method code with example usage: obj.cublas_addmm(size, dtype, reduced_precision) without return types