code: def _resolve_reference_in_domain_by_target(
      inv_name: str | None,
      inventory: Inventory,
      domain: Domain,
      objtypes: Iterable[str],
      target: str,
      node: pending_xref,
      contnode: TextElement,
  ) -> nodes.reference | None:
      for objtype in objtypes:
          if objtype not in inventory:
              # Continue if there's nothing of this kind in the inventory
              continue
  
          if target in inventory[objtype]:
              # Case sensitive match, use it
              data = inventory[objtype][target]
          elif objtype == "std:term":
              # Check for potential case insensitive matches for terms only
              target_lower = target.lower()
              insensitive_matches = list(
                  filter(
                      lambda k: k.lower() == target_lower,
                      inventory[objtype].keys(),
                  )
              )
              if insensitive_matches:
                  data = inventory[objtype][insensitive_matches[0]]
              else:
                  # No case insensitive match either, continue to the next candidate
                  continue
          else:
              # Could reach here if we're not a term but have a case insensitive match.
              # This is a fix for terms specifically, but potentially should apply to
              # other types.
              continue
          return _create_element_from_result(
              domain, inv_name, data, node, contnode
          )
      return None
  
imports: from __future__ import annotations
  import concurrent.futures
  import functools
  import posixpath
  import re
  import sys
  import time
  from os import path
  from typing import TYPE_CHECKING, cast
  from urllib.parse import urlsplit, urlunsplit
  from docutils import nodes
  from docutils.utils import relative_path
  import sphinx
  from sphinx.addnodes import pending_xref
  from sphinx.builders.html import INVENTORY_FILENAME
  from sphinx.errors import ExtensionError
  from sphinx.locale import _, __
  from sphinx.transforms.post_transforms import ReferencesResolver
  from sphinx.util import logging, requests
  from sphinx.util.docutils import CustomReSTDispatcher, SphinxRole
  from sphinx.util.inventory import InventoryFile
label_desc: Use image node_id 8 for calling a global function with example usage: _resolve_reference_in_domain_by_target(inv_name, inventory, domain, objtypes, target, node, contnode) and returns: None, _create_element_from_result