class_docstr: Caches a weak chain of transformations for all bijector instances.
  
  On a cache miss, the other side of the transformation is produced
  and both sides are cached before returning a result. The input object
  is cached with a strong reference, while the transformed output is
  held weakly. When there are no more references to the result, both
  directions of the mapping are cleared simultaneously.
  
  The general contracts are:
    1) The inputs used on cache misses will always be retained
       until their corresponding outputs are abandoned.
    2) `forward` will return a cached result if and only if
       `inverse` would have returned a cached result.
  
  Retaining results in such a manner guarantees that there will be no
  circular references, allowing the garbage collector to remove "dead"
  links from the cache.
  
  Example usage:
  
  ```py
  bij = MyBijector()
  cache = BijectorCache(bijector=bij)
  
  x = tf.constant(1.)
  ref = weakref.ref(x)
  
  for i in range(10):
    assert (len(cache.weak_keys(direction='forward'))
            == len(cache.weak_keys(direction='inverse'))
            == i)
    x = cache.forward(x)
  
  for i in range(10):
    assert len(cache.weak_keys(direction='inverse')) == 10 - i
    x = cache.inverse(x)
    assert len(cache.weak_keys(direction='forward')) == 10 - i
  
  assert len(cache.weak_keys(direction='inverse')) == 0
  assert ref() == x
  
  x = None
  assert len(cache.weak_keys(direction='forward')) == 0
  ```
class_docstr_tok: ["Caches","a","weak","chain","of","transformations","for","all","bijector","instances",".","On","a","cache","miss",",","the","other","side","of","the","transformation","is","produced","and","both","sides","are","cached","before","returning","a","result",".","The","input","object","is","cached","with","a","strong","reference",",","while","the","transformed","output","is","held","weakly",".","When","there","are","no","more","references","to","the","result",",","both","directions","of","the","mapping","are","cleared","simultaneously",".","The","general","contracts","are",":","1",")","The","inputs","used","on","cache","misses","will","always","be","retained","until","their","corresponding","outputs","are","abandoned",".","2",")","`","forward","`","will","return","a","cached","result","if","and","only","if","`","inverse","`","would","have","returned","a","cached","result",".","Retaining","results","in","such","a","manner","guarantees","that","there","will","be","no","circular","references",",","allowing","the","garbage","collector","to","remove","``","dead","''","links","from","the","cache",".","Example","usage",":","``","`","py","bij","=","MyBijector","(",")","cache","=","BijectorCache","(","bijector=bij",")","x","=","tf.constant","(","1",".",")","ref","=","weakref.ref","(","x",")","for","i","in","range","(","10",")",":","assert","(","len","(","cache.weak_keys","(","direction='forward","'",")",")","==","len","(","cache.weak_keys","(","direction='inverse","'",")",")","==","i",")","x","=","cache.forward","(","x",")","for","i","in","range","(","10",")",":","assert","len","(","cache.weak_keys","(","direction='inverse","'",")",")","==","10","-","i","x","=","cache.inverse","(","x",")","assert","len","(","cache.weak_keys","(","direction='forward","'",")",")","==","10","-","i","assert","len","(","cache.weak_keys","(","direction='inverse","'",")",")","==","0","assert","ref","(",")","==","x","x","=","None","assert","len","(","cache.weak_keys","(","direction='forward","'",")",")","==","0","``","`"]
docstr: Defines cache behavior when accessed as a bijector attribute.
  
  We define `__get__` so that the object can be used as a `Bijector` class
  attribute and still access the (eventual) `Bijector` instance without
  requiring that the `Bijector` instance pass `self` back into this cache.
  
  Args:
    bijector: a `tfb.Bijector` instance to which the cache is bound.
    bijector_class: Type of `bijector`.
  
  Returns:
    cache: A `BijectorCache` instance bound to `bijector`.
docstr_tok: ["Defines","cache","behavior","when","accessed","as","a","bijector","attribute",".","We","define","`","__get__","`","so","that","the","object","can","be","used","as","a","`","Bijector","`","class","attribute","and","still","access","the","(","eventual",")","`","Bijector","`","instance","without","requiring","that","the","`","Bijector","`","instance","pass","`","self","`","back","into","this","cache",".","Args",":","bijector",":","a","`","tfb.Bijector","`","instance","to","which","the","cache","is","bound",".","bijector_class",":","Type","of","`","bijector","`",".","Returns",":","cache",":","A","`","BijectorCache","`","instance","bound","to","`","bijector","`","."]
code: def __get__(self, bijector, bijector_class=None):
      """Defines cache behavior when accessed as a bijector attribute.
  
      We define `__get__` so that the object can be used as a `Bijector` class
      attribute and still access the (eventual) `Bijector` instance without
      requiring that the `Bijector` instance pass `self` back into this cache.
  
      Args:
        bijector: a `tfb.Bijector` instance to which the cache is bound.
        bijector_class: Type of `bijector`.
  
      Returns:
        cache: A `BijectorCache` instance bound to `bijector`.
      """
      return type(self)(
          forward_name=self._forward_name,
          inverse_name=self._inverse_name,
          bijector=bijector,
          bijector_class=bijector_class,
          storage=self.storage,
      )
  
imports: import collections
  import weakref
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling the BijectorCache obj's underlying member method code with example usage: obj.__get__(bijector, bijector_class) and returns: type