code: def load_run(
      run_name: Optional[str] = None,
      experiment_name: Optional[str] = None,
      sagemaker_session: Optional["Session"] = None,
      artifact_bucket: Optional[str] = None,
      artifact_prefix: Optional[str] = None,
      tags: Optional[List[Dict[str, str]]] = None,
  ) -> Run:
      """Load an existing run.
  
      In order to reuse an existing run to log extra data, ``load_run`` is recommended.
      It can be used in several ways:
  
      1. Use ``load_run`` by explicitly passing in ``run_name`` and ``experiment_name``.
  
      If ``run_name`` and ``experiment_name`` are passed in, they are honored over
      the default experiment config in the job environment or the run context
      (i.e. within the ``with`` block).
  
      Note:
          Both ``run_name`` and ``experiment_name`` should be supplied to make this usage work.
          Otherwise, you may get a ``ValueError``.
  
      .. code:: python
  
          with load_run(experiment_name="my-exp", run_name="my-run") as run:
              run.log_metric(...)
              ...
  
      2. Use the ``load_run`` in a job script without supplying ``run_name`` and ``experiment_name``.
  
      In this case, the default experiment config (specified when creating the job) is fetched
      from the job environment to load the run.
  
      .. code:: python
  
          # In a job script
          with load_run() as run:
              run.log_metric(...)
              ...
  
      3. Use the ``load_run`` in a notebook within a run context (i.e. the ``with`` block)
      but without supplying ``run_name`` and ``experiment_name``.
  
      Every time we call ``with Run(...) as run1:``, the initialized ``run1`` is tracked
      in the run context. Then when we call ``load_run()`` under this with statement, the ``run1``
      in the context is loaded by default.
  
      .. code:: python
  
          # In a notebook
          with Run(experiment_name="my-exp", run_name="my-run", ...) as run1:
              run1.log_parameter(...)
  
              with load_run() as run2: # run2 is the same object as run1
                  run2.log_metric(...)
                  ...
  
      Args:
          run_name (str): The name of the run to be loaded (default: None).
              If it is None, the ``RunName`` in the ``ExperimentConfig`` of the job will be
              fetched to load the run.
          experiment_name (str): The name of the Experiment that the to be loaded run
              is associated with (default: None).
              Note: the experiment_name must be supplied along with a valid run_name.
              Otherwise, it will be ignored.
          sagemaker_session (sagemaker.session.Session): Session object which
              manages interactions with Amazon SageMaker APIs and any other
              AWS services needed. If not specified, one is created using the
              default AWS configuration chain.
          artifact_bucket (str): The S3 bucket to upload the artifact to.
                  If not specified, the default bucket defined in `sagemaker_session`
                  will be used.
          artifact_prefix (str): The S3 key prefix used to generate the S3 path
              to upload the artifact to (default: "trial-component-artifacts").
          tags (List[Dict[str, str]]): A list of tags to be used for all create calls,
              e.g. to create an experiment, a run group, etc. (default: None).
  
      Returns:
          Run: The loaded Run object.
      """
      environment = _RunEnvironment.load()
  
      verify_load_input_names(
          run_name=run_name, experiment_name=experiment_name
      )
  
      if run_name:
          logger.warning(
              "run_name is explicitly supplied in load_run, "
              "which will be prioritized to load the Run object. "
              "In other words, the run name in the experiment config, fetched from the "
              "job environment or the current run context, will be ignored."
          )
          run_instance = Run(
              experiment_name=experiment_name,
              run_name=run_name,
              sagemaker_session=sagemaker_session
              or _utils.default_session(),
              artifact_bucket=artifact_bucket,
              artifact_prefix=artifact_prefix,
              tags=tags,
          )
      elif _RunContext.get_current_run():
          run_instance = _RunContext.get_current_run()
      elif environment:
          exp_config = get_tc_and_exp_config_from_job_env(
              environment=environment,
              sagemaker_session=sagemaker_session
              or _utils.default_session(),
          )
          run_name = Run._extract_run_name_from_tc_name(
              trial_component_name=exp_config[RUN_NAME],
              experiment_name=exp_config[EXPERIMENT_NAME],
          )
          experiment_name = exp_config[EXPERIMENT_NAME]
          run_instance = Run(
              experiment_name=experiment_name,
              run_name=run_name,
              sagemaker_session=sagemaker_session
              or _utils.default_session(),
              artifact_bucket=artifact_bucket,
              artifact_prefix=artifact_prefix,
              tags=tags,
          )
      else:
          raise RuntimeError(
              "Failed to load a Run object. "
              "Please make sure a Run object has been initialized already."
          )
  
      run_instance._in_load = True
      return run_instance
  
imports: from __future__ import absolute_import
  import datetime
  import logging
  from enum import Enum
  from math import isnan, isinf
  from numbers import Number
  from typing import Optional, List, Dict, TYPE_CHECKING, Union
  import dateutil
  from numpy import array
  from sagemaker.apiutils import _utils
  from sagemaker.experiments import _api_types
  from sagemaker.experiments._api_types import TrialComponentArtifact, _TrialComponentStatusType
  from sagemaker.experiments._helper import _ArtifactUploader, _LineageArtifactTracker, _DEFAULT_ARTIFACT_PREFIX
  from sagemaker.experiments._environment import _RunEnvironment
  from sagemaker.experiments._run_context import _RunContext
  from sagemaker.experiments.experiment import Experiment
  from sagemaker.experiments._metrics import _MetricsManager
  from sagemaker.experiments.trial import _Trial
  from sagemaker.experiments.trial_component import _TrialComponent
  from sagemaker.utils import get_module, unique_name_from_base, format_tags, Tags, TagsDict
  from sagemaker.experiments._utils import guess_media_type, resolve_artifact_name, verify_length_of_true_and_predicted, validate_invoked_inside_run_context, get_tc_and_exp_config_from_job_env, verify_load_input_names, is_run_trial_component
label_desc: Use image node_id 1 for calling a global function with example usage: load_run(run_name, experiment_name, sagemaker_session, artifact_bucket, artifact_prefix, tags) and returns: run_instance