code: def _get_comparison_only_anomalies(
      anomalies: anomalies_pb2.Anomalies,
  ) -> anomalies_pb2.Anomalies:
      """Returns new Anomalies proto with only info from statistics comparison."""
      new_anomalies = anomalies_pb2.Anomalies()
      new_anomalies.CopyFrom(anomalies)
      for feature in list(new_anomalies.anomaly_info):
          # Remove top-level anomaly info description, short_description, and
          # diff_regions entries, since we don't have a good way of separating out the
          # comparison-related portion from the rest.
          new_anomalies.anomaly_info[feature].ClearField("description")
          new_anomalies.anomaly_info[feature].ClearField(
              "short_description"
          )
          new_anomalies.anomaly_info[feature].ClearField("diff_regions")
          reasons_to_keep = [
              r
              for r in new_anomalies.anomaly_info[feature].reason
              if r.type in _COMPARISON_ANOMALY_TYPES
          ]
          del new_anomalies.anomaly_info[feature].reason[:]
          new_anomalies.anomaly_info[feature].reason.extend(
              reasons_to_keep
          )
          # If all of the reasons have been removed, remove the feature's entry from
          # anomaly_info altogether.
          if not new_anomalies.anomaly_info[feature].reason:
              del new_anomalies.anomaly_info[feature]
      new_anomalies.dataset_anomaly_info.ClearField("description")
      new_anomalies.dataset_anomaly_info.ClearField("short_description")
      new_anomalies.dataset_anomaly_info.ClearField("diff_regions")
      dataset_reasons_to_keep = [
          r
          for r in new_anomalies.dataset_anomaly_info.reason
          if r.type in _COMPARISON_ANOMALY_TYPES
      ]
      del new_anomalies.dataset_anomaly_info.reason[:]
      if dataset_reasons_to_keep:
          new_anomalies.dataset_anomaly_info.reason.extend(
              dataset_reasons_to_keep
          )
      else:
          new_anomalies.ClearField("dataset_anomaly_info")
      new_anomalies.ClearField("data_missing")
      return new_anomalies
  
imports: import os
  from typing import Any, Dict
  from absl import logging
  import tensorflow_data_validation
  from tensorflow_data_validation.utils import path
  from tensorflow_data_validation.utils import schema_util
  from tfx import types
  from tfx.components.statistics_gen import stats_artifact_utils
  from tfx.dsl.components.base import base_executor
  from tfx.orchestration.experimental.core import component_generated_alert_pb2
  from tfx.orchestration.experimental.core import constants
  from tfx.proto import distribution_validator_pb2
  from tfx.proto.orchestration import execution_result_pb2
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import json_utils
  from tfx.utils import monitoring_utils
  from tfx.utils import writer_utils
  from google.protobuf import any_pb2
  from tensorflow_metadata.proto.v0 import anomalies_pb2
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _get_comparison_only_anomalies(anomalies) and returns: new_anomalies