code: def relative_error_at(f, *args):
      """Returns the relative error of `f` on `args` in float32.
  
      This function assumes that numerical error when computing `f` in float64 is
      negligible.  For this to work correctly, `f` needs to be _dtype-polymorphic_:
      the dtype in which computations internal to `f` are performed should match the
      dtype of the arguments of `f`.
  
      Note that we are looking for errors due to the implementation of
      `f`, not due to rounding of its inputs or outputs.  Therefore the
      arguments and the result are canonicalized to being representable
      exactly in 32-bit arithmetic.
  
      Args:
        f: Function whose accuracy to evaluate.  Must be dtype-polymorphic.
        *args: Arguments at which to test the accuracy of `f`.
  
      Returns:
        relerr: The relative error when computing `f(*args)` in float32.
  
      Raises:
        ValueError: If `f` is found not to be dtype-polymorphic.
  
      """
      args_32 = tf.nest.map_structure(floating_tensor_to_f32, args)
      logging.vlog(1, "32-bit arguments: %s", args_32)
      args_64 = tf.nest.map_structure(floating_tensor_to_f64, args_32)
      truth = f(*args_64)
      logging.vlog(1, "Correct answer: %s", truth)
      if truth.dtype != tf.float64:
          raise ValueError(
              "Evaluating on {} produced non-64-bit result {}".format(
                  args_64, truth
              )
          )
      truth_32 = floating_tensor_to_f32(truth)
      logging.vlog(
          1, "Correct answer representable in 32 bits: %s", truth_32
      )
      ans_32 = f(*args_32)
      logging.vlog(1, "Answer computed in 32 bits: %s", ans_32)
      if ans_32.dtype != tf.float32:
          raise ValueError(
              "Evaluating on {} produced non-32-bit result {}".format(
                  args_32, ans_32
              )
          )
      return relerr(ans_32, truth_32)
  
file_path: probability/tensorflow_probability/python/internal/numerics_testing.py
imports: import functools
  from absl import logging
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 4 for calling a global function with example usage: relative_error_at(f) and returns: relerr