code: def assert_tensors_equal(a, b, prec=0.0, msg=""):
      assert a.size() == b.size(), msg
      if isinstance(prec, numbers.Number) and prec == 0:
          assert (a == b).all(), msg
          return
      if a.numel() == 0 and b.numel() == 0:
          return
      b = b.type_as(a)
      b = b.cuda(device=a.get_device()) if a.is_cuda else b.cpu()
      if not a.dtype.is_floating_point:
          assert (a == b).all(), msg
          return
      # check that NaNs are in the same locations
      nan_mask = a != a
      assert torch.equal(nan_mask, b != b), msg
      diff = a - b
      diff[a == b] = 0  # handle inf
      diff[nan_mask] = 0
      if diff.is_signed():
          diff = diff.abs()
      if isinstance(prec, torch.Tensor):
          assert (diff <= prec).all(), msg
      else:
          max_err = diff.max().item()
          assert max_err <= prec, msg
  
imports: import contextlib
  import numbers
  import os
  import re
  import warnings
  from itertools import product
  import numpy
  import pytest
  import torch
  import torch.cuda
  from numpy.testing import assert_allclose
  from pytest import approx
label_desc: Use image node_id 12 for calling a global function with example usage: assert_tensors_equal(a, b, prec, msg) without return types