code: def get_tolerances():
      global TOLERANCES
      if TOLERANCES is None:
          # Residual add, as a sequence of casted additions, currently requires a higher tolerance
          # than the other operators for FP16. We should instead better align the behaviors
          # of the reference to match our kernel implementation (TODO(cmikeh2))
          TOLERANCES = {
              torch.float32: (5e-4, 5e-5),
              torch.float16: (3e-2, 4e-3),
          }
          if get_accelerator().is_bf16_supported():
              # Note: BF16 tolerance is higher than FP16 because of the lower precision (7 (+1) bits vs
              # 10 (+1) bits)
              TOLERANCES[torch.bfloat16] = (4.8e-1, 3.2e-2)
      return TOLERANCES
  
file_path: deepspeed/tests/unit/ops/transformer/inference/test_residual_add.py
imports: import pytest
  import torch
  import deepspeed
  from deepspeed.accelerator import get_accelerator
  from deepspeed.ops.op_builder import InferenceBuilder
  from .inference_test_utils import get_dtypes
label_desc: Use image node_id 1 for calling a global function with example usage: get_tolerances() and returns: TOLERANCES