code: def _to_slice_key(feature_value: Any):
      """Decode slice key as UTF-8."""
      # For bytes features we try decoding it as utf-8 (and throw an error if
      # fails). This is because in stats proto the slice name (dataset name) is a
      # string field which can only accept valid unicode.
      if isinstance(feature_value, six.binary_type):
          decoded_value = stats_util.maybe_get_utf8(feature_value)
          if decoded_value is None:
              raise ValueError(
                  "Feature names and slicing feature values must be valid"
                  " UTF-8. Found value {}.".format(feature_value)
              )
          return decoded_value
      return str(feature_value)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from collections import abc
  import functools
  import logging
  from typing import Any, Dict, Iterable, List, Optional, Text, Union, Tuple
  import apache_beam
  import numpy
  import pandas
  import pandas.core.computation.expressions
  import pyarrow
  import six
  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 stats_util
  from tfx_bsl.arrow import array_util
  from tfx_bsl.arrow import sql_util
  from tfx_bsl.arrow import table_util
  from tfx_bsl.public.proto import slicing_spec_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: _to_slice_key(feature_value) and returns: str, decoded_value