code: def extract_type_arg(typ: type, index: int) -> type:
      args = get_args(typ)
      try:
          return cast(type, args[index])
      except IndexError as err:
          raise RuntimeError(
              f"Expected type {typ} to have a type argument at index {index} but it did not"
          ) from err
  
file_path: openai-python/src/openai/_utils/_typing.py
imports: from __future__ import annotations
  from typing import Any, cast
  from typing_extensions import Required, Annotated, get_args, get_origin
  from .._types import InheritsGeneric
  from .._compat import is_union
label_desc: Use image node_id 6 for calling a global function with example usage: extract_type_arg(typ, index) and returns: cast