parameters: (func)
return_statement: return inner
docstring: Internal wrapper caching __getitem__ of generic types with a fallback to
      original function for non-hashable arguments.
docstring_summary: Internal wrapper caching __getitem__ of generic types with a fallback to
      original function for non-hashable arguments.
docstring_tokens: Internal wrapper caching __getitem__ of generic types with a fallback to original function for non - hashable arguments .
function: def _tp_cache(func):
      """Internal wrapper caching __getitem__ of generic types with a fallback to
      original function for non-hashable arguments.
      """
      cached = functools.lru_cache()(func)
      _cleanups.append(cached.cache_clear)
  
      @functools.wraps(func)
      def inner(*args, **kwds):
          try:
              return cached(*args, **kwds)
          except TypeError:
              pass  # All real errors (not unhashable args) are raised below.
          return func(*args, **kwds)
      return inner
function_tokens: def _tp_cache ( func ) : cached = functools . lru_cache ( ) ( func ) _cleanups . append ( cached . cache_clear ) @ functools . wraps ( func ) def inner ( * args , * * kwds ) : try : return cached ( * args , * * kwds ) except TypeError : pass # All real errors (not unhashable args) are raised below. return func ( * args , * * kwds ) return inner