code: def assertAllClose(
      self, tensor1, tensor2, rtol=1e-4, atol=1e-5, equal_nan=False
  ):
      if not tensor1.shape == tensor2.shape:
          raise ValueError(
              f"tensor1 ({tensor1.shape}) and tensor2 ({tensor2.shape}) do not have the same shape."
          )
  
      if torch.allclose(
          tensor1, tensor2, rtol=rtol, atol=atol, equal_nan=equal_nan
      ):
          return True
  
      if not equal_nan:
          if not torch.equal(tensor1, tensor1):
              raise AssertionError(
                  f"tensor1 ({tensor1.shape}) contains NaNs"
              )
          if not torch.equal(tensor2, tensor2):
              raise AssertionError(
                  f"tensor2 ({tensor2.shape}) contains NaNs"
              )
  
      rtol_diff = (
          torch.abs(tensor1 - tensor2) / torch.abs(tensor2)
      ).view(-1)
      rtol_diff = rtol_diff[torch.isfinite(rtol_diff)]
      rtol_max = rtol_diff.max().item()
  
      atol_diff = (
          torch.abs(tensor1 - tensor2) - torch.abs(tensor2).mul(rtol)
      ).view(-1)
      atol_diff = atol_diff[torch.isfinite(atol_diff)]
      atol_max = atol_diff.max().item()
  
      raise AssertionError(
          f"tensor1 ({tensor1.shape}) and tensor2 ({tensor2.shape}) are not close enough. \n"
          f"max rtol: {rtol_max:0.8f}\t\tmax atol: {atol_max:0.8f}"
      )
  
file_path: gpytorch/gpytorch/test/base_test_case.py
imports: import os
  import random
  from abc import ABC
  import torch
label_desc: Use image node_id 3 for calling the BaseTestCase obj's underlying member method code with example usage: obj.assertAllClose(tensor1, tensor2, rtol, atol, equal_nan) and returns: True