code: def _MakeParseFn(
      payload_format: int,
  ) -> Union[
      Callable[[bytes], tf.train.Example],
      Callable[[bytes], tf.train.SequenceExample],
  ]:
      """Returns a function to parse bytes to payload."""
      if (
          payload_format
          == example_gen_pb2.PayloadFormat.FORMAT_TF_EXAMPLE
      ):
          return tf.train.Example.FromString
      elif (
          payload_format
          == example_gen_pb2.PayloadFormat.FORMAT_TF_SEQUENCE_EXAMPLE
      ):
          return tf.train.SequenceExample.FromString
      else:
          raise NotImplementedError(
              "Payload format %s is not supported."
              % example_gen_pb2.PayloadFormat.Name(payload_format)
          )
  
imports: import importlib
  import os
  from typing import Any, Callable, Dict, List, Optional, Union
  from absl import logging
  import apache_beam
  import tensorflow
  from tfx import types
  from tfx.components.bulk_inferrer import prediction_to_example_utils
  from tfx.components.util import model_utils
  from tfx.components.util import tfxio_utils
  from tfx.dsl.components.base import base_beam_executor
  from tfx.proto import bulk_inferrer_pb2
  from tfx.proto import example_gen_pb2
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import io_utils
  from tfx.utils import path_utils
  from tfx.utils import proto_utils
  from tfx_bsl.public.beam import run_inference
  from tfx_bsl.public.proto import model_spec_pb2
  from tfx_bsl.tfxio import record_based_tfxio
  from tensorflow_serving.apis import prediction_log_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _MakeParseFn(payload_format) and returns: tf, tf