class_docstr: PTransform to run AnalyzeAndTransformDataset.
class_docstr_tok: ["PTransform","to","run","AnalyzeAndTransformDataset","."]
code: def expand(self, pipeline):
      # TODO(b/147620802): Consider making this (and other parameters)
      # configurable to test more variants (e.g. with and without deep-copy
      # optimisation, with and without cache, etc).
      with tft_beam.Context(
          temp_dir=tempfile.mkdtemp(),
          force_tf_compat_v1=self._force_tf_compat_v1,
      ):
          raw_data = (
              pipeline
              | "ReadDataset"
              >> beam.Create(
                  self._dataset.read_raw_dataset(
                      deserialize=False, limit=self._max_num_examples
                  )
              )
              | "Decode" >> self._tfxio.BeamSource()
          )
          transform_fn, output_metadata = (
              raw_data,
              self._tfxio.TensorAdapterConfig(),
          ) | "AnalyzeDataset" >> tft_beam.AnalyzeDataset(
              self._preprocessing_fn
          )
  
          if self._generate_dataset:
              _ = transform_fn | "CopySavedModel" >> _CopySavedModel(
                  dest_path=self._dataset.tft_saved_model_path(
                      self._force_tf_compat_v1
                  )
              )
  
          (transformed_dataset, transformed_metadata) = (
              (raw_data, self._tfxio.TensorAdapterConfig()),
              (transform_fn, output_metadata),
          ) | "TransformDataset" >> tft_beam.TransformDataset(
              output_record_batches=True
          )
          return transformed_dataset, transformed_metadata
  
imports: import collections
  import shutil
  import tempfile
  import time
  from absl import logging
  import apache_beam
  from apache_beam.utils import shared
  import tensorflow
  import tensorflow_transform
  from tensorflow_transform import graph_tools
  from tensorflow_transform import impl_helper
  import tensorflow_transform.beam
  from tensorflow_transform.beam import impl
  from tensorflow_transform.saved import saved_transform_io
  from tensorflow_transform.saved import saved_transform_io_v2
  from tensorflow_transform.tf_metadata import dataset_metadata
  from tensorflow_transform.tf_metadata import schema_utils
  import tfx
  from tfx.benchmarks import benchmark_utils
  from tfx.benchmarks import benchmark_base
  from tfx_bsl.coders import example_coder
  from tfx_bsl.tfxio import tensor_adapter
  from tfx_bsl.tfxio import tf_example_record
label_desc: Use image node_id 2 for calling the _AnalyzeAndTransformDataset obj's underlying member method code with example usage: obj.expand(pipeline) and returns: transformed_dataset,  transformed_metadata