code: def get_view(
      pipeline_or_node: Union[
          pipeline_pb2.Pipeline.PipelineOrNode,
          pipeline_pb2.PipelineNode,
          pipeline_pb2.Pipeline,
      ]
  ) -> NodeProtoView:
      """Builds a NodeProtoView adapter from either a Node or a Pipeline proto."""
      if isinstance(
          pipeline_or_node, pipeline_pb2.Pipeline.PipelineOrNode
      ):
          which = pipeline_or_node.WhichOneof("node")
          if which == "pipeline_node":
              return PipelineNodeProtoView(
                  pipeline_or_node.pipeline_node
              )
          elif which == "sub_pipeline":
              return ComposablePipelineProtoView(
                  pipeline_or_node.sub_pipeline
              )
          else:
              raise ValueError("Got unknown pipeline or node type.")
  
      if isinstance(pipeline_or_node, pipeline_pb2.PipelineNode):
          return PipelineNodeProtoView(pipeline_or_node)
  
      if isinstance(pipeline_or_node, pipeline_pb2.Pipeline):
          return ComposablePipelineProtoView(pipeline_or_node)
  
      raise ValueError(
          f"Got unknown pipeline or node type: {pipeline_or_node}."
      )
  
imports: import abc
  from typing import Sequence, Union
  from tfx.dsl.compiler import constants
  from tfx.proto.orchestration import pipeline_pb2
  from google.protobuf import message
label_desc: Use image node_id 1 for calling a global function with example usage: get_view(pipeline_or_node) and returns: PipelineNodeProtoView, ComposablePipelineProtoView, PipelineNodeProtoView, ComposablePipelineProtoView