class_docstr: A Structure stores a Torch Tensor and labeled states.
  Inspired from the paper:
  PatrickStar: Parallel Training of Pre-trained Models via Chunk-based Memory Management
  
  https://arxiv.org/abs/2108.05818
class_docstr_tok: ["A","Structure","stores","a","Torch","Tensor","and","labeled","states",".","Inspired","from","the","paper",":","PatrickStar",":","Parallel","Training","of","Pre-trained","Models","via","Chunk-based","Memory","Management","https",":","\/\/arxiv.org\/abs\/2108.05818"]
code: def __init__(
      self,
      maybe_tensor: Optional[torch.Tensor],
      state: Optional[TensorState] = TensorState.HOLD,
  ) -> None:
      self._state = state
      self._payload = None
      self._payload_size = 0  # byte size of current payload
  
      StatefulTensor.GST_MGR.register_new_instance()
  
      if self._state == TensorState.FREE:
          # when the state is free, payload should be None
          assert (
              maybe_tensor is None
          ), f"payload has to None if state is {self._state}"
      else:
          # otherwise, payload should not be None
          assert (
              maybe_tensor is not None
          ), f"payload can't be None if state is {self._state}"
          self._payload = maybe_tensor
          self._payload_size = sizeof_tensor(maybe_tensor)
          self.__trans_state_update(TensorState.FREE, state)
  
imports: from enum import Enum
  from typing import Optional, Union
  import torch
  from .gemini_context import GeminiMemoryManager
label_desc: Use image node_id 1 to create a new StatefulTensor object from inherited base classes: object with example: obj = StatefulTensor(maybe_tensor, state)