code: def parse(type_: Type[T], obj: Any) -> T:
      if not isinstance(type_, typing._GenericAlias) and issubclass(
          type_, Parameter
      ):
          return type_.parse(obj)
      else:
          # create_model to inject config
          model = pydantic.create_model(
              "parameter", __config__=_SmartUnion, p=(type_, ...)
          )
          return pydantic.parse_obj_as(model, {"p": obj}).p
  
imports: import typing
  from typing import Any, Optional, Type, TypeVar
  import pydantic
label_desc: Use image node_id 1 for calling a global function with example usage: parse(type_, obj) and returns: type_, pydantic