docstr: This class is a detector to detect tensor on different devices.
  
  Args:
      show_info (bool, optional): whether to print the info on screen, default True.
      log (str, optional): the file name to save the log. Defaults to None.
      include_cpu (bool, optional): whether to detect tensor on cpu, default False.
      module (Optional[:class:`nn.Module`]): when sending an ``nn.Module`` object,
          the detector can name the tensors detected better.
docstr_tok: ["This","class","is","a","detector","to","detect","tensor","on","different","devices",".","Args",":","show_info","(","bool",",","optional",")",":","whether","to","print","the","info","on","screen",",","default","True",".","log","(","str",",","optional",")",":","the","file","name","to","save","the","log",".","Defaults","to","None",".","include_cpu","(","bool",",","optional",")",":","whether","to","detect","tensor","on","cpu",",","default","False",".","module","(","Optional","[",":","class",":","`","nn.Module","`","]",")",":","when","sending","an","``","nn.Module","``","object",",","the","detector","can","name","the","tensors","detected","better","."]
code: def __init__(
      self,
      show_info: bool = True,
      log: str = None,
      include_cpu: bool = False,
      module: Optional[nn.Module] = None,
  ):
      """This class is a detector to detect tensor on different devices.
  
      Args:
          show_info (bool, optional): whether to print the info on screen, default True.
          log (str, optional): the file name to save the log. Defaults to None.
          include_cpu (bool, optional): whether to detect tensor on cpu, default False.
          module (Optional[:class:`nn.Module`]): when sending an ``nn.Module`` object,
              the detector can name the tensors detected better.
      """
      self.show_info = show_info
      self.log = log
      self.include_cpu = include_cpu
      self.tensor_info = defaultdict(list)
      self.saved_tensor_info = defaultdict(list)
      self.order = []
      self.detected = []
      self.devices = []
      self.info = ""
  
      self.module = module
      if isinstance(module, nn.Module):
          # if module is an instance of nn.Module, we can name the parameter with its real name
          for name, param in module.named_parameters():
              self.tensor_info[id(param)].append(name)
              self.tensor_info[id(param)].append(param.device)
              self.tensor_info[id(param)].append(param.shape)
              self.tensor_info[id(param)].append(param.requires_grad)
              self.tensor_info[id(param)].append(param.dtype)
              self.tensor_info[id(param)].append(
                  self.get_tensor_mem(param)
              )
  
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 1 to create a new TensorDetector object  with example: obj = TensorDetector(show_info, log, include_cpu, module)