class_docstr: Metaclass to support subtyping with parameters for pattern matching, e.g. ``Number[int, int]``.
class_docstr_tok: ["Metaclass","to","support","subtyping","with","parameters","for","pattern","matching",",","e.g",".","``","Number","[","int",",","int","]","``","."]
code: def __getitem__(cls, arg_types):
      if not isinstance(arg_types, tuple):
          arg_types = (arg_types,)
      arg_types = tuple(map(_type_to_typing, arg_types))
      try:
          return cls._type_cache[arg_types]
      except KeyError:
          assert not get_args(
              cls
          ), "cannot subscript a subscripted type {}".format(cls)
          assert not any(
              isvariadic(arg_type) for arg_type in arg_types
          ), "nested variadic types not supported"
          new_dct = cls.__dict__.copy()
          new_dct.update({"__args__": arg_types})
          # type(cls) to handle GenericTypeMeta subclasses
          result = type(cls)(cls.__name__, (cls,), new_dct)
          cls._type_cache[arg_types] = result
          return result
  
imports: import functools
  import sys
  import typing
  import weakref
  import typing_extensions
  from multipledispatch.variadic import Variadic
  from multipledispatch.variadic import isvariadic
label_desc: Use image node_id 2 for calling the GenericTypeMeta obj's underlying member method code with example usage: obj.__getitem__(cls, arg_types) and returns: cls, result