class_docstr: A generic that takes a primitive type as its single argument.
docstr: Return the result of `_PrimitiveTypeGeneric[T]` for a given type T.
docstr_tok: ["Return","the","result","of","`","_PrimitiveTypeGeneric","[","T","]","`","for","a","given","type","T","."]
code: def _generic_getitem(cls, params):
      """Return the result of `_PrimitiveTypeGeneric[T]` for a given type T."""
      # Check that the given parameter is a primitive type.
      if (
          inspect.isclass(params)
          and params in (int, float, str, bool)
          or json_compat.is_json_compatible(params)
      ):
          return cls(params, _init_via_getitem=True)
      else:
          class_name = cls.__name__
          raise ValueError(
              (
                  "Generic type `%s[T]` expects the single parameter T to be "
                  "`int`, `float`, `str`, `bool` or JSON-compatible types "
                  "(Dict[str, T], List[T]) (got %r instead)."
              )
              % (class_name, params)
          )
  
imports: import inspect
  from typing import Any, Dict, Generic, List, Type, TypeVar, Union, get_args, get_origin
  from tfx.dsl.component.experimental import json_compat
  from tfx.types import artifact
  from tfx.utils import deprecation_utils
label_desc: Use image node_id 2 for calling the _PrimitiveTypeGeneric obj's underlying member method code with example usage: obj._generic_getitem(cls, params) and returns: cls