code: def test_check_is_instance(obj, classinfo, allow_subclass, name):
      if isinstance(classinfo, list):
          with pytest.raises(TypeError):
              check_is_instance(obj, classinfo)
          return
  
      if allow_subclass:
          if isinstance(obj, classinfo):
              check_is_instance(obj, classinfo)
          else:
              with pytest.raises(
                  TypeError, match="Object must be an instance of"
              ):
                  check_is_instance(obj, classinfo)
              with pytest.raises(
                  TypeError, match=f"{name} must be an instance of"
              ):
                  check_is_instance(obj, classinfo, name=name)
  
      else:
          if type(classinfo) is tuple:
              if type(obj) in classinfo:
                  check_is_type(obj, classinfo)
              else:
                  with pytest.raises(
                      TypeError,
                      match=f"{name} must have one of the following types",
                  ):
                      check_is_type(obj, classinfo, name=name)
                  with pytest.raises(
                      TypeError,
                      match="Object must have one of the following types",
                  ):
                      check_is_type(obj, classinfo)
          elif get_origin(classinfo) is Union:
              if type(obj) in get_args(classinfo):
                  check_is_type(obj, classinfo)
              else:
                  with pytest.raises(
                      TypeError,
                      match=f"{name} must have one of the following types",
                  ):
                      check_is_type(obj, classinfo, name=name)
                  with pytest.raises(
                      TypeError,
                      match="Object must have one of the following types",
                  ):
                      check_is_type(obj, classinfo)
          else:
              if type(obj) is classinfo:
                  check_is_type(obj, classinfo)
              else:
                  with pytest.raises(
                      TypeError, match=f"{name} must have type"
                  ):
                      check_is_type(obj, classinfo, name=name)
                  with pytest.raises(
                      TypeError, match="Object must have type"
                  ):
                      check_is_type(obj, classinfo)
  
      msg = "Name must be a string, got <class 'int'> instead."
      with pytest.raises(TypeError, match=msg):
          check_is_instance(0, int, name=0)
  
imports: from collections import namedtuple
  from re import escape
  import sys
  from typing import Union, get_args, get_origin
  import numpy
  import pytest
  from vtk import vtkTransform
  from pyvista.core import pyvista_ndarray
  from pyvista.core.input_validation.check import _validate_shape_value, check_has_length, check_has_shape, check_is_arraylike, check_is_dtypelike, check_is_finite, check_is_greater_than, check_is_in_range, check_is_instance, check_is_integerlike, check_is_iterable, check_is_iterable_of_some_type, check_is_iterable_of_strings, check_is_less_than, check_is_nonnegative, check_is_number, check_is_real, check_is_scalar, check_is_sequence, check_is_sorted, check_is_string, check_is_string_in_iterable, check_is_subdtype, check_is_type
  from pyvista.core.input_validation.validate import _set_default_kwarg_mandatory, validate_array, validate_array3, validate_arrayN, validate_arrayN_uintlike, validate_arrayNx3, validate_axes, validate_data_range, validate_dtype, validate_number, validate_transform3x3, validate_transform4x4
  from pyvista.core.utilities.arrays import cast_to_tuple_array, vtkmatrix_from_array
label_desc: Use image node_id 21 for calling a global function with example usage: test_check_is_instance(obj, classinfo, allow_subclass, name) without return types