code: def _check_type(
      arg_name: str,
      arg_values: Any,
      expected_type: Union[Type[Any], Tuple[Type[Any], ...]],
      element_type: Optional[
          Union[Type[Any], Tuple[Type[Any], ...]]
      ] = None,
  ) -> None:
      if isinstance(expected_type, tuple):
          class_names = [cls.__name__ for cls in expected_type]
          expected_type_string = ", ".join(class_names)
      else:
          expected_type_string = expected_type.__name__
  
      element_type_string = None
      if element_type is not None:
          if isinstance(element_type, tuple):
              class_names = [cls.__name__ for cls in element_type]
              element_type_string = ", ".join(class_names)
          else:
              element_type_string = element_type.__name__
  
      validation_failed = False
  
      if not isinstance(arg_values, expected_type):
          validation_failed = True
  
      if element_type is not None:
          if isinstance(arg_values, pd.DataFrame) and not all(
              arg_values.dtypes == element_type
          ):
              validation_failed = True
  
          if isinstance(arg_values, np.ndarray):
              if (
                  arg_values.ndim == 2
                  and not arg_values.dtype == element_type
              ):
                  validation_failed = True
              elif arg_values.ndim == 1 and not all(
                  isinstance(val, element_type) for val in arg_values
              ):
                  validation_failed = True
  
          elif isinstance(arg_values, List) and not all(
              isinstance(val, element_type) for val in arg_values
          ):
              validation_failed = True
  
      if validation_failed:
          error_msg = f"Error: {arg_name} is expected to be {expected_type_string}"
          if element_type_string:
              error_msg += f" with dtype '{element_type_string}'"
          raise TypeError(error_msg)
  
file_path: FinQuant/finquant/type_utilities.py
imports: import datetime
  from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
  import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: _check_type(arg_name, arg_values, expected_type, element_type) without return types