code: def compare_anomalies(output_uri: str, expected_uri: str) -> bool:
      """Compares anomalies files in output uri and recorded uri.
  
      Looks at only binary proto files.
  
      Args:
        output_uri: pipeline output artifact uri.
        expected_uri: recorded pipeline output artifact uri.
  
      Returns:
         boolean whether anomalies are same.
      """
      for dir_name, _, leaf_files in fileio.walk(expected_uri):
          for leaf_file in leaf_files:
              if not leaf_file.endswith(".pb"):
                  # Do not analyze non-binary-proto files.
                  continue
              expected_file_name = os.path.join(dir_name, leaf_file)
              file_name = os.path.join(
                  dir_name.replace(expected_uri, output_uri, 1),
                  leaf_file,
              )
              anomalies = anomalies_pb2.Anomalies()
              anomalies.ParseFromString(
                  io_utils.read_bytes_file(
                      os.path.join(output_uri, file_name)
                  )
              )
              expected_anomalies = anomalies_pb2.Anomalies()
              expected_anomalies.ParseFromString(
                  io_utils.read_bytes_file(
                      os.path.join(expected_uri, expected_file_name)
                  )
              )
              if (
                  expected_anomalies.anomaly_info
                  != anomalies.anomaly_info
              ):
                  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 9 for calling a global function with example usage: compare_anomalies(output_uri, expected_uri) and returns: True, False