code: def is_instance_factory(
      _type: type | tuple[type, ...]
  ) -> Callable[[Any], None]:
      """
  
      Parameters
      ----------
      `_type` - the type to be checked against
  
      Returns
      -------
      validator - a function of a single argument x , which raises
                  ValueError if x is not an instance of `_type`
  
      """
      if isinstance(_type, tuple):
          type_repr = "|".join(map(str, _type))
      else:
          type_repr = f"'{_type}'"
  
      def inner(x) -> None:
          if not isinstance(x, _type):
              raise ValueError(
                  f"Value must be an instance of {type_repr}"
              )
  
      return inner
  
imports: from __future__ import annotations
  from contextlib import ContextDecorator, contextmanager
  import re
  from typing import TYPE_CHECKING, Any, Callable, Generic, NamedTuple, cast
  import warnings
  from pandas._typing import F, T
  from pandas.util._exceptions import find_stack_level
label_desc: Use image node_id 20 for calling a global function with example usage: is_instance_factory(_type) and returns: inner