code: def check_is_instance(
      obj, /, classinfo, *, allow_subclass=True, name="Object"
  ):
      """Check if an object is an instance of the given type or types.
  
      Parameters
      ----------
      obj : Any
          Object to check.
  
      classinfo : type | tuple[type, ...]
          ``type`` or tuple of types. Object must be an instance of one of
          the types.
  
      allow_subclass : bool, default: True
          If ``True``, the object's type must be specified by ``classinfo``
           or any of its subclasses. Otherwise, subclasses are not allowed.
  
      name : str, default: "Object"
          Variable name to use in the error messages if any are raised.
  
      Raises
      ------
      TypeError
          If object is not an instance of any of the given types.
  
      See Also
      --------
      check_is_type
      check_is_number
      check_is_string
      check_is_iterable
      check_is_sequence
  
      Examples
      --------
      Check if an object is an instance of ``complex``.
  
      >>> import pyvista.core.input_validation as valid
      >>> valid.check_is_instance(1 + 2j, complex)
  
      Check if an object is an instance of one of several types.
  
      >>> valid.check_is_instance("eggs", (int, str))
  
      """
      if not isinstance(name, str):
          raise TypeError(
              f"Name must be a string, got {type(name)} instead."
          )
  
      # Get class info from generics
      if get_origin(classinfo) is Union:
          classinfo = get_args(classinfo)
  
      # Count num classes
      if isinstance(classinfo, tuple):
          num_classes = len(classinfo)
      else:
          num_classes = 1
  
      # Check if is instance
      is_instance = isinstance(obj, classinfo)
  
      # Set flag to raise error if not instance
      is_error = False
      if allow_subclass and not is_instance:
          is_error = True
          if num_classes == 1:
              msg_body = "must be an instance of"
          else:
              msg_body = "must be an instance of any type"
  
      # Set flag to raise error if not type
      elif not allow_subclass:
          if isinstance(classinfo, tuple):
              if type(obj) not in classinfo:
                  is_error = True
                  msg_body = "must have one of the following types"
          elif type(obj) is not classinfo:
              is_error = True
              msg_body = "must have type"
  
      if is_error:
          msg = (
              f"{name} {msg_body} {classinfo}. Got {type(obj)} instead."
          )
          raise TypeError(msg)
  
imports: from collections.abc import Iterable, Sequence
  from numbers import Number
  from typing import Tuple, Union, get_args, get_origin
  import numpy
  from pyvista.core.utilities.arrays import cast_to_ndarray
label_desc: Use image node_id 17 for calling a global function with example usage: check_is_instance(classinfo) without return types