code: def _merge_custom_anomalies(
      anomalies: anomalies_pb2.Anomalies,
      custom_anomalies: anomalies_pb2.Anomalies,
  ) -> anomalies_pb2.Anomalies:
      """Merges custom_anomalies with anomalies."""
      for (
          key,
          custom_anomaly_info,
      ) in custom_anomalies.anomaly_info.items():
          if key in anomalies.anomaly_info:
              # If the key is found in in both inputs, we know it has multiple errors.
              anomalies.anomaly_info[
                  key
              ].short_description = _MULTIPLE_ERRORS
              anomalies.anomaly_info[
                  key
              ].description = _merge_descriptions(
                  anomalies.anomaly_info[key], custom_anomaly_info
              )
              anomalies.anomaly_info[key].severity = max(
                  anomalies.anomaly_info[key].severity,
                  custom_anomaly_info.severity,
              )
              anomalies.anomaly_info[key].reason.extend(
                  custom_anomaly_info.reason
              )
          else:
              anomalies.anomaly_info[key].CopyFrom(custom_anomaly_info)
              # Also populate top-level descriptions.
              anomalies.anomaly_info[
                  key
              ].description = _merge_descriptions(
                  custom_anomaly_info, None
              )
              if len(anomalies.anomaly_info[key].reason) > 1:
                  anomalies.anomaly_info[
                      key
                  ].short_description = _MULTIPLE_ERRORS
              else:
                  anomalies.anomaly_info[
                      key
                  ].short_description = custom_anomaly_info.reason[
                      0
                  ].short_description
      return anomalies
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import logging
  from typing import Callable, Iterable, List, Optional, Text, Tuple, Set
  import apache_beam
  import pyarrow
  import tensorflow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.anomalies.proto import custom_validation_config_pb2
  from tensorflow_data_validation.anomalies.proto import validation_config_pb2
  from tensorflow_data_validation.anomalies.proto import validation_metadata_pb2
  from tensorflow_data_validation.api import validation_options
  from tensorflow_data_validation.pywrap.tensorflow_data_validation_extension import validation
  from tensorflow_data_validation.skew import feature_skew_detector
  from tensorflow_data_validation.skew.protos import feature_skew_results_pb2
  from tensorflow_data_validation.statistics import stats_impl
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import anomalies_util
  from tensorflow_data_validation.utils import slicing_util
  from tensorflow_data_validation.utils import stats_util
  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 5 for calling a global function with example usage: _merge_custom_anomalies(anomalies, custom_anomalies) and returns: anomalies