code: def _has_original_dunder(
      value,
      allowed_types,
      allowed_methods,
      allowed_external,
      method_name,
  ):
      # note: Python ignores `__getattr__`/`__getitem__` on instances,
      # we only need to check at class level
      value_type = type(value)
  
      # strict type check passes → no need to check method
      if value_type in allowed_types:
          return True
  
      method = getattr(value_type, method_name, None)
  
      if method is None:
          return None
  
      if method in allowed_methods:
          return True
  
      for module_name, *access_path in allowed_external:
          if _has_original_dunder_external(
              value, module_name, access_path, method_name
          ):
              return True
  
      return False
  
imports: from inspect import signature, Signature
  from typing import Any, Callable, Dict, Set, Sequence, Tuple, NamedTuple, Type, Literal, Union, TYPE_CHECKING
  import ast
  import builtins
  import collections
  import operator
  import sys
  from functools import cached_property
  from dataclasses import dataclass, field
  from types import MethodDescriptorType, ModuleType
  from IPython.utils.docs import GENERATING_DOCUMENTATION
  from IPython.utils.decorators import undoc
label_desc: Use image node_id 4 for calling a global function with example usage: _has_original_dunder(value, allowed_types, allowed_methods, allowed_external, method_name) and returns: False, True, None, True, True