code: def arrays_all_close(test_obj, a, b, atol, msg=None):
      """Check if two arrays are within a tolerance specified per element.
  
      Checks that a, b and atol have the same shape and that
        `abs(a_i - b_i) <= atol_i` for all elements of `a` and `b`.
      This function differs from np.testing.assert_allclose() as
      np.testing.assert_allclose() applies the same `atol` to all of the elements,
      whereas this function takes a `ndarray` specifying a `atol` for each element.
  
      Args:
        test_obj: An object which has the `evaluate` method. Used to evaluate `a` if
          `a` is a Tensor.
        a: The expected numpy `ndarray`, or anything that can be converted into a
           numpy `ndarray` (including Tensor), or any arbitrarily nested of
           structure of these.
        b: The actual numpy `ndarray`, or anything that can be converted into a
           numpy `ndarray` (including Tensor), or any arbitrarily nested of
           structure of these.
        atol: absolute tolerance as a numpy `ndarray` of the same shape as `a` and
           `b`.
        msg: Optional message to include in the error message.
      Raises:
        ValueError: If `a`, `b` and `atol` do not have the same shape.
        AssertionError: If any of the elements are outside the tolerance.
      """
      # TODO(b/177990397): This function should be independent of the test framework
      a = convert_to_ndarray(test_obj, a)
      b = convert_to_ndarray(test_obj, b)
      atol = convert_to_ndarray(test_obj, atol)
      # Check the shapes are the same.
      if a.shape != b.shape:
          raise ValueError(
              "Mismatched shapes a.shape() = {}".format(a.shape)
              + ", b.shape= {}".format(b.shape)
              + ", atol.shape = {}".format(atol.shape)
              + ". ({}).".format(msg)
          )
      abs_diff = np.abs(a - b)
      if np.any(abs_diff >= atol):
          raise ValueError(
              "Expected and actual values differ by more than the "
              + "tolerance.\n a = {}".format(a)
              + "\n b = {}".format(b)
              + "\n abs_diff = {}".format(abs_diff)
              + "\n atol = {}".format(atol)
              + "\n When {}.".format(msg)
          )
      return
  
file_path: tf-quant-finance/tf_quant_finance/models/geometric_brownian_motion/geometric_brownian_motion_test_utils.py
imports: import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
label_desc: Use image node_id 2 for calling a global function with example usage: arrays_all_close(test_obj, a, b, atol, msg) without return types