def num_in_memory(self):
    """Get number of values in memory."""
    n = len(self._data) - 1
    while n >= 0:
      if isinstance(self._data[n], _TensorValueDiscarded):
        break
      n -= 1
    return len(self._data) - 1 - n
Get number of values in memory.