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"]
docstr: Update global manager when changing the device of a tensor
docstr_tok: ["Update","global","manager","when","changing","the","device","of","a","tensor"]
code: def __trans_device_update(self, from_type: str, to_type: str):
      """Update global manager when changing the device of a tensor"""
      manager = StatefulTensor.GST_MGR
      size = self.payload_size
      state = self.state
  
      # update aggregated information
      manager.total_mem[from_type] -= size
      manager.total_mem[to_type] += size
  
      # update the information of each state
      manager.state_mem[from_type][state] -= size
      manager.state_mem[to_type][state] += size
  
imports: from enum import Enum
  from typing import Optional, Union
  import torch
  from .gemini_context import GeminiMemoryManager
label_desc: Use image node_id 20 for calling the StatefulTensor obj's underlying member method code with example usage: obj.__trans_device_update(from_type, to_type) without return types