code: def test_locking():
      """Tests that report pauses training until fetch_next or finish."""
  
      def train_1():
          import _thread
  
          _thread.interrupt_main()
  
      init_session(
          training_func=train_1,
          world_rank=0,
          local_rank=0,
          node_rank=0,
          local_world_size=1,
          world_size=1,
          storage=storage,
      )
      session = get_session()
      with pytest.raises(KeyboardInterrupt):
          session.start()
      shutdown_session()
  
      def train_2():
          for i in range(2):
              report(dict(loss=i))
          train_1()
  
      init_session(
          training_func=train_2,
          world_rank=0,
          local_rank=0,
          node_rank=0,
          local_world_size=1,
          world_size=1,
          storage=storage,
      )
      session = get_session()
      session.start()
      time.sleep(3)
  
      session.pause_reporting()
      # Releases session.continue_lock to resume the training thread.
      session.get_next()
  
      with pytest.raises(KeyboardInterrupt):
          session.get_next()
      session.finish()
      shutdown_session()
  
imports: import tempfile
  import time
  import warnings
  import pytest
  import ray
  from ray.air._internal.util import StartTraceback
  from ray.air.constants import SESSION_MISUSE_LOG_ONCE_KEY
  from ray.air.session import get_checkpoint, get_dataset_shard, get_local_rank, get_world_rank, get_world_size, report
  from ray.train._internal.accelerator import Accelerator
  from ray.train._internal.session import get_accelerator, get_session, init_session, set_accelerator, shutdown_session
  from ray.train._internal.storage import StorageContext
  from ray.train.error import SessionMisuseError
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
label_desc: Use image node_id 16 for calling a global function with example usage: test_locking() without return types