code: def get_slice_stats(
      stats: statistics_pb2.DatasetFeatureStatisticsList,
      slice_key: Text,
  ) -> statistics_pb2.DatasetFeatureStatisticsList:
      """Get statistics associated with a specific slice.
  
      Args:
        stats: A DatasetFeatureStatisticsList protocol buffer.
        slice_key: Slice key of the slice.
  
      Returns:
        Statistics of the specific slice.
  
      Raises:
        ValueError: If the input statistics proto does not have the specified slice
          statistics.
      """
      for slice_stats in stats.datasets:
          if slice_stats.name == slice_key:
              result = statistics_pb2.DatasetFeatureStatisticsList()
              result.datasets.add().CopyFrom(slice_stats)
              return result
      raise ValueError("Invalid slice key.")
  
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 12 for calling a global function with example usage: get_slice_stats(stats, slice_key) and returns: result