code: def test_enter_exit_locally(mock_load_tc, sagemaker_session, run_obj):
      mock_load_tc.return_value = run_obj._trial_component, False
      sagemaker_session.sagemaker_client.update_trial_component.return_value = (
          {}
      )
      _verify_tc_status_before_enter_init(run_obj._trial_component)
  
      with run_obj:
          _verify_tc_status_when_entering(run_obj._trial_component)
          init_start_time = run_obj._trial_component.start_time
  
          with load_run(sagemaker_session=sagemaker_session):
              _verify_tc_status_when_entering(
                  trial_component=run_obj._trial_component,
                  init_start_time=init_start_time,
              )
  
          old_end_time = _verify_tc_status_when_successfully_exit(
              trial_component=run_obj._trial_component,
          )
  
      old_end_time = _verify_tc_status_when_successfully_exit(
          trial_component=run_obj._trial_component,
          old_end_time=old_end_time,
      )
  
      # Re-load to verify:
      # 1. if it works when load_run and with are not in one line
      # 2. if re-entering the load will change the "Completed" TC status
      # to "InProgress"
      # 3. when exiting the load, the end_time and status will be overridden again
      run_load = load_run(
          experiment_name=run_obj.experiment_name,
          run_name=run_obj.run_name,
          sagemaker_session=sagemaker_session,
      )
      with run_load:
          _verify_tc_status_when_entering(
              trial_component=run_obj._trial_component,
              init_start_time=init_start_time,
              has_completed=True,
          )
      _verify_tc_status_when_successfully_exit(
          trial_component=run_obj._trial_component,
          old_end_time=old_end_time,
      )
  
imports: from __future__ import absolute_import
  import datetime
  import unittest
  import cloudpickle
  from math import inf, nan
  from unittest.mock import patch, Mock, MagicMock
  import dateutil
  import pytest
  from sagemaker.experiments import _environment, SortOrderType
  from sagemaker.experiments._api_types import TrialComponentArtifact, TrialComponentSummary, TrialComponentStatus, _TrialComponentStatusType, TrialComponentSearchResult
  from sagemaker.experiments.experiment import Experiment
  from sagemaker.experiments.run import TRIAL_NAME_TEMPLATE, MAX_RUN_TC_ARTIFACTS_LEN, MAX_NAME_LEN_IN_BACKEND, EXPERIMENT_NAME, RUN_NAME, TRIAL_NAME, DELIMITER, RUN_TC_TAG, SortByType
  from sagemaker.experiments import Run, load_run, list_runs
  from sagemaker.experiments.trial import _Trial
  from sagemaker.experiments.trial_component import _TrialComponent
  from sagemaker.experiments._helper import _DEFAULT_ARTIFACT_PREFIX
  from tests.unit.sagemaker.experiments.helpers import mock_trial_load_or_create_func, mock_tc_load_or_create_func, TEST_EXP_NAME, TEST_EXP_NAME_MIXED_CASE, TEST_RUN_NAME, TEST_EXP_DISPLAY_NAME, TEST_RUN_DISPLAY_NAME, TEST_ARTIFACT_BUCKET, TEST_ARTIFACT_PREFIX, TEST_TAGS
label_desc: Use image node_id 45 for calling a global function with example usage: test_enter_exit_locally(mock_load_tc, sagemaker_session, run_obj) without return types