code: def validate_type(*, type_: type[_T], value: object) -> _T:
      """Strict validation that the given value matches the expected type"""
      if inspect.isclass(type_) and issubclass(
          type_, pydantic.BaseModel
      ):
          return cast(_T, parse_obj(type_, value))
  
      return cast(
          _T, _validate_non_model_type(type_=type_, value=value)
      )
  
imports: from __future__ import annotations
  import inspect
  from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
  from datetime import date, datetime
  from typing_extensions import Unpack, Literal, ClassVar, Protocol, Required, TypedDict, final, override, runtime_checkable
  import pydantic
  import pydantic.generics
  from pydantic.fields import FieldInfo
  from ._types import Body, IncEx, Query, ModelT, Headers, Timeout, NotGiven, AnyMapping, HttpxRequestFiles
  from ._utils import is_list, is_given, is_mapping, parse_date, parse_datetime, strip_not_given
  from ._compat import PYDANTIC_V2, ConfigDict, GenericModel, get_args, is_union, parse_obj, get_origin, is_literal_type, get_model_config, get_model_fields, field_get_default
  from ._constants import RAW_RESPONSE_HEADER
label_desc: Use image node_id 4 for calling a global function with example usage: validate_type() and returns: cast, cast