code: def print_tensors_state(self):
      template_format = (
          "{:3s}{:<30s}{:>10s}{:>20s}{:>10s}{:>20s}{:>15s}"
      )
      self.info += LINE
      self.info += template_format.format(
          "  ", "Tensor", "device", "shape", "grad", "dtype", "Mem"
      )
      self.info += "\n"
      self.info += LINE
  
      # if a tensor updates this turn, and was recorded before
      # it should be updated in the saved_tensor_info as well
      outdated = [
          x for x in self.saved_tensor_info.keys() if x in self.order
      ]
      minus = [
          x
          for x in self.saved_tensor_info.keys()
          if x not in self.detected
      ]
      minus = outdated + minus
      if len(self.order) > 0:
          for tensor_id in self.order:
              self.info += template_format.format(
                  "+",
                  str(self.tensor_info[tensor_id][0]),
                  str(self.tensor_info[tensor_id][1]),
                  str(tuple(self.tensor_info[tensor_id][2])),
                  str(self.tensor_info[tensor_id][3]),
                  str(self.tensor_info[tensor_id][4]),
                  str(self.tensor_info[tensor_id][5]),
              )
              self.info += "\n"
      if len(self.order) > 0 and len(minus) > 0:
          self.info += "\n"
      if len(minus) > 0:
          for tensor_id in minus:
              self.info += template_format.format(
                  "-",
                  str(self.saved_tensor_info[tensor_id][0]),
                  str(self.saved_tensor_info[tensor_id][1]),
                  str(tuple(self.saved_tensor_info[tensor_id][2])),
                  str(self.saved_tensor_info[tensor_id][3]),
                  str(self.saved_tensor_info[tensor_id][4]),
                  str(self.saved_tensor_info[tensor_id][5]),
              )
              self.info += "\n"
              # deleted the updated tensor
              self.saved_tensor_info.pop(tensor_id)
  
      # trace where is the detect()
      locate_info = inspect.stack()[2]
      locate_msg = (
          '"'
          + locate_info.filename
          + '" line '
          + str(locate_info.lineno)
      )
  
      self.info += LINE
      self.info += f"Detect Location: {locate_msg}\n"
      for device in self.devices:
          if device == torch.device("cpu"):
              continue
          gpu_mem_alloc = self.mem_format(
              torch.cuda.memory_allocated(device)
          )
          self.info += f"Total GPU Memory Allocated on {device} is {gpu_mem_alloc}\n"
      self.info += LINE
      self.info += "\n\n"
      if self.show_info:
          print(self.info)
      if self.log is not None:
          with open(self.log + ".log", "a") as f:
              f.write(self.info)
  
file_path: ColossalAI/colossalai/utils/tensor_detector/tensor_detector.py
imports: import gc
  import inspect
  from collections import defaultdict
  from typing import Optional
  import torch
  import torch.nn
label_desc: Use image node_id 5 for calling the TensorDetector obj's underlying member method code with example usage: obj.print_tensors_state() without return types