code: def _compare_relative_difference(
      value: float, expected_value: float, threshold: float
  ) -> bool:
      """Compares relative difference between value and expected_value against threshold.
  
      Args:
        value: a float value to be compared to expected value.
        expected_value: a float value that is expected.
        threshold: a float larger than 0.
  
      Returns:
        a boolean indicating whether the relative difference is within the
        threshold.
      """
      if value != expected_value:
          if expected_value:
              relative_diff = abs(value - expected_value) / abs(
                  expected_value
              )
              if not (expected_value and relative_diff <= threshold):
                  logging.warning(
                      "Relative difference %f exceeded threshold %f",
                      relative_diff,
                      threshold,
                  )
                  return False
      return True
  
imports: import filecmp
  import os
  from typing import Dict, List, Optional
  from absl import logging
  import tensorflow_model_analysis
  from tfx import types
  from tfx.dsl.io import fileio
  from tfx.experimental.pipeline_testing import pipeline_recorder_utils
  from tfx.orchestration import metadata
  from tfx.types import artifact_utils
  from tfx.utils import io_utils
  from ml_metadata.proto import metadata_store_pb2
  from tensorflow_metadata.proto.v0 import anomalies_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _compare_relative_difference(value, expected_value, threshold) and returns: True, False