code: def _GeneratePartitionKey(
      record: Union[
          tf.train.Example,
          tf.train.SequenceExample,
          bytes,
          Dict[str, Any],
      ],
      split_config: example_gen_pb2.SplitConfig,
  ) -> bytes:
      """Generates key for partition."""
  
      if not split_config.HasField("partition_feature_name"):
          if isinstance(record, bytes):
              return record
          if isinstance(record, dict):
              return pickle.dumps(record)
          return record.SerializeToString(deterministic=True)
  
      if isinstance(record, tf.train.Example):
          features = (
              record.features.feature
          )  # pytype: disable=attribute-error
      elif isinstance(record, tf.train.SequenceExample):
          features = (
              record.context.feature
          )  # pytype: disable=attribute-error
      else:
          raise RuntimeError(
              "Split by `partition_feature_name` is only supported "
              "for FORMAT_TF_EXAMPLE and FORMAT_TF_SEQUENCE_EXAMPLE "
              "payload format."
          )
  
      # Use a feature for partitioning the examples.
      feature_name = split_config.partition_feature_name
      if feature_name not in features:
          raise RuntimeError(
              "Feature name `{}` does not exist.".format(feature_name)
          )
      feature = features[feature_name]
      if not feature.HasField("kind"):
          raise RuntimeError(
              "Partition feature does not contain any value."
          )
      if not feature.HasField("bytes_list") and not feature.HasField(
          "int64_list"
      ):
          raise RuntimeError(
              "Only `bytes_list` and `int64_list` features are "
              "supported for partition."
          )
      return feature.SerializeToString(deterministic=True)
  
imports: import abc
  import bisect
  import hashlib
  import pickle
  from typing import Any, Dict, List, Union
  from absl import logging
  import apache_beam
  import tensorflow
  from tfx import types
  from tfx.components.example_gen import utils
  from tfx.components.example_gen import write_split
  from tfx.components.util import examples_utils
  from tfx.dsl.components.base import base_beam_executor
  from tfx.proto import example_gen_pb2
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import proto_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _GeneratePartitionKey(record, split_config) and returns: feature, record, record, pickle