code: def get_metadata(
      workflow_id: str, task_id: Optional[str] = None
  ) -> Dict[str, Any]:
      """Get the metadata of the workflow.
  
      This will return a dict of metadata of either the workflow (
      if only workflow_id is given) or a specific workflow task (if
      both workflow_id and task id are given). Exception will be
      raised if the given workflow id or task id does not exist.
  
      If only workflow id is given, this will return metadata on
      workflow level, which includes running status, workflow-level
      user metadata and workflow-level running stats (e.g. the
      start time and end time of the workflow).
  
      If both workflow id and task id are given, this will return
      metadata on workflow task level, which includes task inputs,
      task-level user metadata and task-level running stats (e.g.
      the start time and end time of the task).
  
  
      Args:
          workflow_id: The workflow to get the metadata of.
          task_id: If set, fetch the metadata of the specific task instead of
              the metadata of the workflow.
  
      Examples:
          .. testcode::
  
              from ray import workflow
  
              @ray.remote
              def trip():
                 pass
  
              workflow_task = trip.options(
                  **workflow.options(task_id="trip", metadata={"k1": "v1"})).bind()
              workflow.run(workflow_task,
                  workflow_id="trip1", metadata={"k2": "v2"})
              workflow_metadata = workflow.get_metadata("trip1")
              print(workflow_metadata)
  
              task_metadata = workflow.get_metadata("trip1", "trip")
              print(task_metadata)
  
          .. testoutput::
  
              {'status': 'SUCCESSFUL', 'user_metadata': {'k2': 'v2'}, 'stats': {'start_time': ..., 'end_time': ...}}
              {'task_id': 'trip', 'task_options': {'task_type': 'FUNCTION', 'max_retries': 3, 'catch_exceptions': False, 'retry_exceptions': False, 'checkpoint': True, 'ray_options': {'_metadata': {'workflow.io/options': {'task_id': 'trip', 'metadata': {'k1': 'v1'}}}}}, 'user_metadata': {'k1': 'v1'}, 'workflow_refs': [], 'stats': {'start_time': ..., 'end_time': ...}}
  
      Returns:
          A dictionary containing the metadata of the workflow.
  
      Raises:
          ValueError: if given workflow or workflow task does not exist.
      """  # noqa: E501
      _ensure_workflow_initialized()
      store = WorkflowStorage(workflow_id)
      if task_id is None:
          return store.load_workflow_metadata()
      else:
          return store.load_task_metadata(task_id)
  
imports: import functools
  import logging
  import tempfile
  from typing import Dict, Set, List, Tuple, Union, Optional, Any
  import time
  import uuid
  from pathlib import Path
  import ray
  from ray.dag import DAGNode
  from ray.dag.input_node import DAGInputData
  from ray.remote_function import RemoteFunction
  from ray.workflow.common import WorkflowStatus, Event, asyncio_run, validate_user_metadata
  from ray.workflow import serialization, workflow_access, workflow_context
  from ray.workflow.event_listener import EventListener, EventListenerType, TimerListener
  from ray.workflow.workflow_storage import WorkflowStorage
  from ray.workflow.workflow_state_from_dag import workflow_state_from_dag
  from ray.util.annotations import PublicAPI
  from ray._private.usage import usage_lib
label_desc: Use image node_id 15 for calling a global function with example usage: get_metadata(workflow_id, task_id) and returns: store, store