code: def analyze_test_numerics(
      test_results: model_handler.TestResultCollection,
      use_cpu_baseline: bool,
  ) -> (DataFrame, str):
      """Analyzes test numerics."""
      preprocess_funcs = {"abs_diff": lambda x, y: np.fabs(x - y)}
      postprocess_funcs = {"mean": np.mean}
      column_names = []
      columns = []
      base_result = (
          test_results.cpu_base_result
          if use_cpu_baseline
          else test_results.gpu_base_result
      )
      if base_result is None:
          raise ValueError(
              f"No {'CPU' if use_cpu_baseline else 'GPU'} baseline found!"
          )
      for fn0, fn1 in itertools.product(
          preprocess_funcs, postprocess_funcs
      ):
          func0, func1 = preprocess_funcs[fn0], postprocess_funcs[fn1]
          column_names.append("{}_{}".format(fn0, fn1))
          columns.append([])
          for result in test_results.results:
              columns[-1].append(dict())
              for idx, tensor in enumerate(result.output_tensors):
                  name = base_result.output_names[idx]
                  cpu_tensor = base_result.output_tensors[idx]
                  absdiff = func0(tensor, cpu_tensor)
                  metric_value = func1(absdiff).item()
                  cpu_tensor_hist = str_histogram(
                      cpu_tensor, "cpu_tensor"
                  )
                  gpu_tensor_hist = str_histogram(tensor, "gpu_tensor")
                  abs_diff_hist = str_histogram(absdiff, "abs_diff")
                  hist_data = (
                      cpu_tensor_hist,
                      gpu_tensor_hist,
                      abs_diff_hist,
                  )
                  columns[-1][-1][name] = metric_value
      return (
          DataFrame(column_names=column_names, columns=columns),
          hist_data,
      )
  
imports: import itertools
  import json
  from typing import Any, Callable, Optional, Sequence, Tuple, Union
  from collections import namedtuple
  import numpy
  from tensorflow.python.compiler.tensorrt.model_tests import model_handler
  import tensorflow.python.compiler.tensorrt.trt_convert
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 4 for calling a global function with example usage: analyze_test_numerics(test_results, use_cpu_baseline) and returns: DataFrame,  hist_data