code: def assert_tensors_close(a, b, atol=1e-12, prefix=""):
      """If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error."""
      if a is None and b is None:
          return True
      try:
          if torch.allclose(a, b, atol=atol):
              return True
          raise
      except Exception:
          pct_different = (
              (torch.gt((a - b).abs(), atol)).float().mean().item()
          )
          if a.numel() > 100:
              msg = f"tensor values are {pct_different:.1%} percent different."
          else:
              msg = f"{a} != {b}"
          if prefix:
              msg = prefix + ": " + msg
          raise AssertionError(msg)
  
imports: import copy
  import tempfile
  import unittest
  from transformers import MBartConfig, is_torch_available
  from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, require_torch_fp16, slow, torch_device
  from transformers.utils import cached_property
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 2 for calling a global function with example usage: assert_tensors_close(a, b, atol, prefix) and returns: True, True