code: def import_ivar_by_name(
      name: str,
      prefixes: Sequence[str | None] = (None,),
      grouped_exception: bool = True,
  ) -> tuple[str, Any, Any, str]:
      """Import an instance variable that has the given *name*, under one of the
      *prefixes*.  The first name that succeeds is used.
      """
      try:
          name, attr = name.rsplit(".", 1)
          real_name, obj, parent, modname = import_by_name(
              name, prefixes
          )
  
          # Get ancestors of the object (class.__mro__ includes the class itself as
          # the first entry)
          candidate_objects = getmro(obj)
          if len(candidate_objects) == 0:
              candidate_objects = (obj,)
  
          for candidate_obj in candidate_objects:
              analyzer = ModuleAnalyzer.for_module(
                  getattr(candidate_obj, "__module__", modname)
              )
              analyzer.analyze()
              # check for presence in `annotations` to include dataclass attributes
              found_attrs = set()
              found_attrs |= {
                  attr for (qualname, attr) in analyzer.attr_docs
              }
              found_attrs |= {
                  attr for (qualname, attr) in analyzer.annotations
              }
              if attr in found_attrs:
                  return (
                      real_name + "." + attr,
                      INSTANCEATTR,
                      obj,
                      modname,
                  )
      except (ImportError, ValueError, PycodeError) as exc:
          raise ImportError from exc
      except ImportExceptionGroup:
          raise  # pass through it as is
  
      raise ImportError
  
imports: from __future__ import annotations
  import functools
  import inspect
  import operator
  import os
  import posixpath
  import re
  import sys
  from inspect import Parameter
  from os import path
  from types import ModuleType
  from typing import TYPE_CHECKING, Any, cast
  from docutils import nodes
  from docutils.parsers.rst import directives
  from docutils.parsers.rst.states import RSTStateMachine, Struct, state_classes
  from docutils.statemachine import StringList
  import sphinx
  from sphinx import addnodes
  from sphinx.config import Config
  from sphinx.environment import BuildEnvironment
  from sphinx.ext.autodoc import INSTANCEATTR, Documenter
  from sphinx.ext.autodoc.directive import DocumenterBridge, Options
  from sphinx.ext.autodoc.importer import import_module
  from sphinx.ext.autodoc.mock import mock
  from sphinx.locale import __
  from sphinx.project import Project
  from sphinx.pycode import ModuleAnalyzer, PycodeError
  from sphinx.registry import SphinxComponentRegistry
  from sphinx.util import logging, rst
  from sphinx.util.docutils import NullReporter, SphinxDirective, SphinxRole, new_document, switch_source_input
  from sphinx.util.inspect import getmro, signature_from_str
  from sphinx.util.matching import Matcher
label_desc: Use image node_id 13 for calling a global function with example usage: import_ivar_by_name(name, prefixes, grouped_exception) and returns: unknown,  INSTANCEATTR,  obj,  modname