code: def api_method(f):
      # Decorator that adds the decorated class method as a callable
      # function (wrapped) to catalyst.api
      @wraps(f)
      def wrapped(*args, **kwargs):
          # Get the instance and call the method
          algo_instance = get_algo_instance()
          if algo_instance is None:
              raise RuntimeError(
                  "catalyst api method %s must be called during a simulation."
                  % f.__name__
              )
          return getattr(algo_instance, f.__name__)(*args, **kwargs)
  
      # Add functor to catalyst.api
      setattr(catalyst.api, f.__name__, wrapped)
      catalyst.api.__all__.append(f.__name__)
      f.is_api_method = True
      return f
  
file_path: catalyst/catalyst/utils/api_support.py
imports: from functools import wraps
  import catalyst.api
  from catalyst.utils.algo_instance import get_algo_instance, set_algo_instance
label_desc: Use image node_id 1 for calling a global function with example usage: api_method(f) and returns: f, getattr