class_docstr: weakref.ref object for tensors, np.ndarray, and structures.
  
  Invokes the callback when any element of the struct's ref-count drops to 0.
class_docstr_tok: ["weakref.ref","object","for","tensors",",","np.ndarray",",","and","structures",".","Invokes","the","callback","when","any","element","of","the","struct","'s","ref-count","drops","to","0","."]
code: def __init__(self, struct, subkey=None, callback=None):
      wrap = lambda x: HashableWeakRef(x, self._cleanup)
      self._struct = nest.map_structure(wrap, struct)
      # Copy subkey to avoid mutations.
      self._subkey = nest.map_structure((lambda x: x), subkey)
      # Because `struct` and `subkey` are both immutable containers,
      # we assume that their hashes are stable and unchanging.
      # Compute the hash and store it with the object.
      self._hash = hash(
          hashable_structure((self._struct, self._subkey))
      )
      self._callback = callback
      self._alive = True
  
imports: import collections
  import weakref
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new WeakStructRef object from inherited base classes: object with example: obj = WeakStructRef(struct, subkey, callback)