code: def test_run_init_under_run_load_context(
      mock_load_tc,
      mock_load_trial,
      mock_load_exp,
      run_obj,
      sagemaker_session,
  ):
      mock_load_tc.return_value = run_obj._trial_component, True
      mock_load_trial.return_value = run_obj._trial
      mock_load_exp.return_value = run_obj._experiment
      assert not _RunContext.get_current_run()
  
      with pytest.raises(RuntimeError) as err:
          with load_run(
              run_name=run_obj.run_name,
              experiment_name=run_obj.experiment_name,
              sagemaker_session=sagemaker_session,
          ):
              assert _RunContext.get_current_run()
  
              with Run(
                  experiment_name=TEST_EXP_NAME,
                  sagemaker_session=sagemaker_session,
              ):
                  pass
      assert (
          "It is not allowed to use nested 'with' statements on the Run"
          in str(err)
      )
  
imports: from __future__ import absolute_import
  from unittest.mock import patch, MagicMock
  import pytest
  from sagemaker import Processor
  from sagemaker.estimator import Estimator, _TrainingJob
  from sagemaker.experiments.experiment import Experiment
  from sagemaker.experiments.run import _RunContext
  from sagemaker.experiments import load_run, Run
  from sagemaker.experiments.trial import _Trial
  from sagemaker.experiments.trial_component import _TrialComponent
  from sagemaker.processing import ProcessingJob
  from sagemaker.transformer import _TransformJob, Transformer
  from tests.unit.sagemaker.experiments.helpers import TEST_EXP_NAME, mock_trial_load_or_create_func, mock_tc_load_or_create_func
label_desc: Use image node_id 10 for calling a global function with example usage: test_run_init_under_run_load_context(mock_load_tc, mock_load_trial, mock_load_exp, run_obj, sagemaker_session) without return types