class_docstr: Visitor that constructs the beam pipeline from the node graph.
class_docstr_tok: ["Visitor","that","constructs","the","beam","pipeline","from","the","node","graph","."]
code: def visit(self, operation, inputs):
      try:
          ptransform_wrapper = _PTRANSFORM_BY_OPERATION_DEF_SUBCLASS[
              operation.__class__
          ]
          environment_tag = (
              EnvironmentTags.TF_COMPAT_V1
              if self._extra_args.use_tf_compat_v1
              else EnvironmentTags.TF_V2_ONLY
          )
          ptransform, tag = ptransform_wrapper.get_ptransform(
              environment_tag
          )
      except KeyError:
          raise ValueError(
              "No implementation for {} was registered".format(
                  operation
              )
          )
  
      # TODO(zoyahav): Consider extracting a single PCollection before passing to
      # ptransform if len(inputs) == 1.
      if tag is None:
          tagged_label = operation.label
      else:
          tagged_label = "{label}[{tag}]".format(
              label=operation.label, tag=tag
          )
      try:
          outputs = (
              inputs or beam.pvalue.PBegin(self._extra_args.pipeline)
          ) | tagged_label >> ptransform(operation, self._extra_args)
      except Exception as e:
          raise RuntimeError(
              "Failed to apply: {}".format(tagged_label)
          ) from e
  
      if isinstance(outputs, beam.pvalue.PCollection):
          return (outputs,)
      else:
          return outputs
  
imports: import collections
  import dataclasses
  import enum
  import os
  from typing import Any, Dict, Mapping, Optional
  import uuid
  import apache_beam
  from tensorflow_transform import common_types
  from tensorflow_transform import nodes
  from tfx_bsl.telemetry import util
label_desc: Use image node_id 2 for calling the ConstructBeamPipelineVisitor obj's underlying member method code with example usage: obj.visit(operation, inputs) and returns: outputs, outputs