code: def Write(
      evaluation_or_validation: Union[
          evaluator.Evaluation, validator.Validation
      ],
      key: str,
      ptransform: beam.PTransform,
  ) -> Optional[beam.PCollection]:
      """Writes given Evaluation or Validation data using given writer PTransform.
  
      Args:
        evaluation_or_validation: Evaluation or Validation data.
        key: Key for Evaluation or Validation output to write. It is valid for the
          key to not exist in the dict (in which case the write is a no-op).
        ptransform: PTransform to use for writing.
  
      Raises:
        ValueError: If Evaluation or Validation is empty. The key does not need to
          exist in the Evaluation or Validation, but the dict must not be empty.
  
      Returns:
        The result of the underlying beam write PTransform. This makes it possible
        for interactive environments to execute your writer, as well as for
        downstream Beam stages to make use of the files that are written.
      """
      if not evaluation_or_validation:
          raise ValueError(
              "Evaluations and Validations cannot be empty"
          )
      if key in evaluation_or_validation:
          return evaluation_or_validation[key] | ptransform
      return None
  
imports: from typing import NamedTuple, Optional, Union
  import apache_beam
  from tensorflow_model_analysis.evaluators import evaluator
  from tensorflow_model_analysis.validators import validator
label_desc: Use image node_id 1 for calling a global function with example usage: Write(evaluation_or_validation, key, ptransform) and returns: None, unknown