code: def _validate_type(
      item, types=None, item_name=None, type_name=None, *, extra=""
  ):
      """Validate that `item` is an instance of `types`.
  
      Parameters
      ----------
      item : object
          The thing to be checked.
      types : type | str | tuple of types | tuple of str
           The types to be checked against.
           If str, must be one of {'int', 'int-like', 'str', 'numeric', 'info',
           'path-like', 'callable', 'array-like'}.
           If a tuple of str is passed, use 'int-like' and not 'int' for integers.
      item_name : str | None
          Name of the item to show inside the error message.
      type_name : str | None
          Possible types to show inside the error message that the checked item
          can be.
      extra : str
          Extra text to append to the warning.
      """
      if types == "int":
          _ensure_int(item, name=item_name, extra=extra)
          return  # terminate prematurely
      elif types == "info":
          from .._fiff.meas_info import Info as types
  
      if not isinstance(types, (list, tuple)):
          types = [types]
  
      check_types = sum(
          (
              (type(None),)
              if type_ is None
              else (type_,)
              if not isinstance(type_, str)
              else _multi[type_]
              for type_ in types
          ),
          (),
      )
      extra = f" {extra}" if extra else extra
      if not isinstance(item, check_types):
          if type_name is None:
              type_name = [
                  "None"
                  if cls_ is None
                  else cls_.__name__
                  if not isinstance(cls_, str)
                  else cls_
                  for cls_ in types
              ]
              if len(type_name) == 1:
                  type_name = type_name[0]
              elif len(type_name) == 2:
                  type_name = " or ".join(type_name)
              else:
                  type_name[-1] = "or " + type_name[-1]
                  type_name = ", ".join(type_name)
          _item_name = "Item" if item_name is None else item_name
          raise TypeError(
              f"{_item_name} must be an instance of {type_name}{extra}, "
              f"got {type(item)} instead."
          )
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 26 for calling a global function with example usage: _validate_type(item, types, item_name, type_name) without return types