code: def get_type_str(
      cls: Union[type, str, None]
  ) -> str:  # pylint: disable=too-many-return-statements
      """Return a string representing the type ``cls``.
  
      If cls is a built-in type, such as 'str', returns the unqualified
          name.
  
      If cls is a parametrized generic such as List[str], or a special typing
          form such as Optional[int], returns the string representation of cls.
  
      Otherwise, returns the fully-qualified class name, including the module.
      """
      if cls is None or cls is type(None):
          return "None"
  
      if isinstance(cls, str):
          return cls
  
      if isinstance(cls, ForwardRef):
          # String annotations, as in List['MyClass']
          return cls.__forward_arg__
  
      if isinstance(cls, _SpecialForm):
          # These are typing constructs like Union, Literal etc that
          # are not parametrized
          return cls._name  # pylint: disable=protected-access
  
      orig_type = get_origin(cls)
      if orig_type is not None:
          # This is either a parametrized generic or parametrized special form
          orig_args = get_args(cls)
          if orig_args:
              return f"{get_type_str(orig_type)}[{', '.join(get_type_str(arg) for arg in orig_args)}]"
  
          return get_type_str(orig_type)
  
      if getattr(cls, "__module__", None) in ("builtins", None):
          # This is a built-in type
          return cls.__name__
  
      # Regular class
      return f"{cls.__module__}.{cls.__qualname__}"
  
file_path: pennylane/pennylane/data/base/typing_util.py
imports: from enum import Enum
  from functools import lru_cache
  from typing import Any, Dict, ForwardRef, List, Literal, Optional, Tuple, Type, TypeVar, Union, _SpecialForm, get_args, get_origin
label_desc: Use image node_id 2 for calling a global function with example usage: get_type_str(cls) and returns: cls, str, cls, str, cls, cls, cls, get_type_str, cls, get_type_str, str, str, str