code: def client_mode_hook(func: callable):
      """Decorator for whether to use the 'regular' ray version of a function,
      or the Ray Client version of that function.
  
      Args:
          func: This function. This is set when this function is used
              as a decorator.
      """
  
      from ray.util.client import ray
  
      @wraps(func)
      def wrapper(*args, **kwargs):
          # NOTE(hchen): DO NOT use "import" inside this function.
          # Because when it's called within a `__del__` method, this error
          # will be raised (see #35114):
          # ImportError: sys.meta_path is None, Python is likely shutting down.
          if client_mode_should_convert():
              # Legacy code
              # we only convert init function if RAY_CLIENT_MODE=1
              if (
                  func.__name__ != "init"
                  or is_client_mode_enabled_by_default
              ):
                  return getattr(ray, func.__name__)(*args, **kwargs)
          return func(*args, **kwargs)
  
      return wrapper
  
file_path: ray/python/ray/_private/client_mode_hook.py
imports: import os
  import threading
  from contextlib import contextmanager
  from functools import wraps
  from ray._private.auto_init_hook import auto_init_ray
label_desc: Use image node_id 8 for calling a global function with example usage: client_mode_hook(func) and returns: wrapper, func, getattr