code: def build_output_artifact_spec(
      channel_spec: channel.Channel,
  ) -> pipeline_pb2.ComponentOutputsSpec.ArtifactSpec:
      """Builds artifact type spec for an output channel."""
      # We use the first artifact instance if available from channel, otherwise
      # create one.
      result = pipeline_pb2.ComponentOutputsSpec.ArtifactSpec()
      result.artifact_type.CopyFrom(
          pipeline_pb2.ArtifactTypeSchema(
              instance_schema=get_artifact_schema(channel_spec.type)
          )
      )
  
      _validate_properties_schema(
          instance_schema=result.artifact_type.instance_schema,
          properties=channel_spec.type.PROPERTIES,
      )
  
      if channel_spec.additional_properties:
          result.metadata.update(channel_spec.additional_properties)
      if channel_spec.additional_custom_properties:
          result.metadata.update(
              channel_spec.additional_custom_properties
          )
      return result
  
imports: import itertools
  import json
  import os
  import re
  from typing import Any, Dict, List, Mapping, Optional, Type, Union
  from kfp.pipeline_spec import pipeline_spec_pb2
  from tfx import types
  from tfx.dsl.io import fileio
  from tfx.orchestration import data_types
  from tfx.orchestration.kubeflow.v2 import parameter_utils
  from tfx.proto.orchestration import placeholder_pb2
  from tfx.types import artifact
  from tfx.types import channel
  from tfx.types import standard_artifacts
  from tfx.types.experimental import simple_artifacts
  from tfx.utils import json_utils
  from tfx.utils import name_utils
  import yaml
  from google.protobuf import struct_pb2
  from google.protobuf import json_format
  from google.protobuf import message
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: build_output_artifact_spec(channel_spec) and returns: result