code: def _get_session_id(thread_id: int) -> Tuple[int, bool]:
      """Returns (session_id, direct_call) tuple."""
      session_id = _THREAD_TO_SESSIONID.get(thread_id, None)
      if session_id:
          direct_call = False
      else:
          direct_call = True
          with _NEXT_SESSION_ID_LOCK:
              global _NEXT_SESSION_ID
              session_id = _NEXT_SESSION_ID
              _THREAD_TO_SESSIONID[thread_id] = session_id
              _NEXT_SESSION_ID += 1
      return session_id, direct_call
  
file_path: datasets/tensorflow_datasets/core/logging/call_metadata.py
imports: import enum
  import threading
  import time
  from typing import Dict, Optional, Tuple
label_desc: Use image node_id 1 for calling a global function with example usage: _get_session_id(thread_id) and returns: session_id,  direct_call