code: def enclosing_scope_name(ensure_estimator=True, stack_level=2):
      """Find the name of the enclosing scope for debug output purpose.
  
      Use inspection to climb up the stack until the calling object. This is
      typically used to get the estimator at the origin of a functional call
      for debug print purpose.
  
      Parameters
      ----------
      ensure_estimator : boolean, default=True
          If true, find the enclosing object deriving from 'BaseEstimator'.
  
      stack_level : integer, default=2
          If ensure_estimator is not True, stack_level quantifies the
          number of frame we will go up.
  
      """
      try:
          frame = inspect.currentframe()
          if not ensure_estimator:
              for _ in range(stack_level):
                  frame = frame.f_back
          else:
              while True:
                  frame = frame.f_back
                  if "self" not in frame.f_locals:
                      continue
                  if not isinstance(
                      frame.f_locals["self"], BaseEstimator
                  ):
                      continue
                  break
          if "self" in frame.f_locals:
              caller_name = frame.f_locals["self"].__class__.__name__
              caller_name = f"{caller_name}.{frame.f_code.co_name}"
          else:
              caller_name = frame.f_code.co_name
  
          return caller_name
      except AuthorizedException:
          return "Unknown"
  
imports: import inspect
  from sklearn.base import BaseEstimator
  from .exceptions import AuthorizedException
label_desc: Use image node_id 2 for calling a global function with example usage: enclosing_scope_name(ensure_estimator, stack_level) and returns: caller_name, str