code: def generate_output_artifacts(
      execution_id: int,
      outputs: Mapping[str, pipeline_pb2.OutputSpec],
      node_dir: str,
  ) -> Dict[str, List[types.Artifact]]:
      """Generates output artifacts.
  
      Args:
        execution_id: The id of the execution.
        outputs: Mapping from artifact key to its OutputSpec value in pipeline IR.
        node_dir: The root directory of the node.
  
      Returns:
        Mapping from artifact key to the list of TFX artifacts.
      """
  
      output_artifacts = collections.defaultdict(list)
      for key, output_spec in outputs.items():
          artifact = _generate_output_artifact(output_spec)
          if output_spec.artifact_spec.external_artifact_uris:
              for (
                  external_uri
              ) in output_spec.artifact_spec.external_artifact_uris:
                  external_artifact = copy.deepcopy(artifact)
                  external_artifact.uri = external_uri
                  external_artifact.is_external = True
  
                  logging.debug(
                      "Creating external output artifact uri %s",
                      external_artifact.uri,
                  )
                  output_artifacts[key].append(external_artifact)
  
          else:
              artifact.uri = os.path.join(
                  node_dir, key, str(execution_id)
              )
              if isinstance(artifact, ValueArtifact):
                  artifact.uri = os.path.join(
                      artifact.uri, _VALUE_ARTIFACT_FILE_NAME
                  )
  
              logging.debug(
                  "Creating output artifact uri %s", artifact.uri
              )
              output_artifacts[key].append(artifact)
  
      return output_artifacts
  
imports: import collections
  import copy
  import datetime
  import os
  from typing import Any, Dict, List, Mapping, Optional, Sequence, Union
  import uuid
  from absl import logging
  from tfx import types
  from tfx import version
  from tfx.dsl.io import fileio
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import node_proto_view
  from tfx.orchestration.experimental.core import constants
  from tfx.orchestration.portable import data_types
  from tfx.proto.orchestration import execution_result_pb2
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.types import artifact
  from tfx.types import artifact_utils
  from tfx.types.value_artifact import ValueArtifact
  from tfx.utils import proto_utils
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 7 for calling a global function with example usage: generate_output_artifacts(execution_id, outputs, node_dir) and returns: output_artifacts