code: def get_custom_stats(
      feature_stats: statistics_pb2.FeatureNameStatistics,
      custom_stats_name: Text,
  ) -> Union[
      float,
      Text,
      statistics_pb2.Histogram,
      statistics_pb2.RankHistogram,
  ]:
      """Get custom statistics from the feature statistics.
  
      Args:
        feature_stats: A FeatureNameStatistics protocol buffer.
        custom_stats_name: The name of the custom statistics to obtain from the
          feature statistics proto.
  
      Returns:
        The custom statistic.
  
      Raises:
        TypeError: If the input feature statistics is not of the expected type.
        ValueError: If the custom statistic is not found in the feature statistics.
      """
      if not isinstance(
          feature_stats, statistics_pb2.FeatureNameStatistics
      ):
          raise TypeError(
              "feature_stats is of type %s, should be a "
              "FeatureNameStatistics proto."
              % type(feature_stats).__name__
          )
  
      for custom_stats in feature_stats.custom_stats:
          if custom_stats.name == custom_stats_name:
              return getattr(
                  custom_stats, custom_stats.WhichOneof("val")
              )
  
      raise ValueError(
          "Custom statistics %s not found in the feature statistics."
          % custom_stats_name
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  from typing import Dict, Iterable, Optional, Sequence, Text, Tuple, Union
  import numpy
  import pyarrow
  import tensorflow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.arrow import arrow_util
  from tensorflow_data_validation.utils import artifacts_io_impl
  from tensorflow_data_validation.utils import io_util
  from tfx_bsl import statistics
  from tfx_bsl.arrow import array_util
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 11 for calling a global function with example usage: get_custom_stats(feature_stats, custom_stats_name) and returns: getattr