code: def get_context() -> TrainContext:
      """Get or create a singleton training context.
  
      The context is only available in a training or tuning loop.
  
      See the :class:`~ray.train.TrainContext` API reference to see available methods.
      """
      global _default_context
  
      with _context_lock:
          if _default_context is None:
              _default_context = TrainContext()
          return _default_context
  
file_path: ray/python/ray/train/context.py
imports: import threading
  from typing import TYPE_CHECKING, Any, Dict, Optional
  from ray.train._internal import session
  from ray.train._internal.storage import StorageContext
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 2 for calling a global function with example usage: get_context() and returns: _default_context