class_docstr: Generic TFX import example gen executor.
docstr: Returns PTransform for importing records.
docstr_tok: ["Returns","PTransform","for","importing","records","."]
code: def GetInputSourceToExamplePTransform(self) -> beam.PTransform:
      """Returns PTransform for importing records."""
  
      @beam.ptransform_fn
      @beam.typehints.with_input_types(beam.Pipeline)
      @beam.typehints.with_output_types(
          Union[
              tf.train.Example,
              tf.train.SequenceExample,
              bytes,
              Dict[str, Any],
          ]
      )
      def ImportRecord(
          pipeline: beam.Pipeline,
          exec_properties: Dict[str, Any],
          split_pattern: str,
      ) -> beam.pvalue.PCollection:
          """PTransform to import records.
  
          The records are tf.train.Example, tf.train.SequenceExample,
          or serialized proto.
  
          Args:
            pipeline: Beam pipeline.
            exec_properties: A dict of execution properties.
              - input_base: input dir that contains input data.
            split_pattern: Split.pattern in Input config, glob relative file pattern
              that maps to input files with root directory given by input_base.
  
          Returns:
            PCollection of records (tf.Example, tf.SequenceExample, or bytes).
          """
          output_payload_format = exec_properties.get(
              standard_component_specs.OUTPUT_DATA_FORMAT_KEY
          )
  
          if (
              output_payload_format
              == example_gen_pb2.PayloadFormat.FORMAT_PARQUET
          ):
              return pipeline | _ImportParquetRecord(
                  exec_properties, split_pattern
              )  # pylint: disable=no-value-for-parameter
  
          serialized_records = (
              pipeline
              # pylint: disable=no-value-for-parameter
              | _ImportSerializedRecord(exec_properties, split_pattern)
          )
          if (
              output_payload_format
              == example_gen_pb2.PayloadFormat.FORMAT_PROTO
          ):
              return serialized_records
          elif (
              output_payload_format
              == example_gen_pb2.PayloadFormat.FORMAT_TF_EXAMPLE
          ):
              return serialized_records | "ToTFExample" >> beam.Map(
                  tf.train.Example.FromString
              )
          elif (
              output_payload_format
              == example_gen_pb2.PayloadFormat.FORMAT_TF_SEQUENCE_EXAMPLE
          ):
              return (
                  serialized_records
                  | "ToTFSequenceExample"
                  >> beam.Map(tf.train.SequenceExample.FromString)
              )
  
          raise ValueError(
              "output_payload_format must be one of FORMAT_TF_EXAMPLE,"
              " FORMAT_TF_SEQUENCE_EXAMPLE, FORMAT_PROTO or FORMAT_PARQUET"
          )
  
      return ImportRecord
  
file_path: tfx/tfx/components/example_gen/import_example_gen/executor.py
imports: import os
  from typing import Any, Dict, Union
  from absl import logging
  import apache_beam
  import pyarrow.parquet
  import tensorflow
  from tfx.components.example_gen import base_example_gen_executor
  from tfx.dsl.io import fileio
  from tfx.proto import example_gen_pb2
  from tfx.types import standard_component_specs
label_desc: Use image node_id 1 for calling the Executor obj's underlying member method code with example usage: obj.GetInputSourceToExamplePTransform() and returns: ImportRecord, unknown, serialized_records, unknown, unknown