code: def _is_method_context(
      component: Union["LightningFlow", "LightningWork"],
      selected_caller_name: str,
  ) -> bool:
      """Checks whether the call to a component originates from within the context of the component's ``__init__``
      method."""
      frame = inspect.currentframe().f_back
  
      while frame is not None:
          caller_name = frame.f_code.co_name
          caller_self = frame.f_locals.get("self")
          if (
              caller_name == selected_caller_name
              and caller_self is component
          ):
              # the call originates from a frame under component.__init__
              return True
          frame = frame.f_back
  
      return False
  
imports: import ast
  import inspect
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Type, Union
label_desc: Use image node_id 1 for calling a global function with example usage: _is_method_context(component, selected_caller_name) and returns: False, True