class_docstr: A naive implementation of LazyTensor (https://arxiv.org/pdf/2102.13267.pdf).
  
  Usage:
      1. Use ``LazyTensor`` instead of ``torch.Tensor``.
      >>> x = LazyTensor(torch.zeros, 2, 3)
      >>> x += 1
      >>> y = x * x
      >>> y = y.cuda().half()
      >>> y[0, 0] = 0
      >>> y = y.materialize()     # materialize the tensor
      >>> print(y)
      tensor([[0., 1., 1.],
              [1., 1., 1.]], device='cuda:0', dtype=torch.float16)
  
  Warnings:
      1. Cases that ``LazyTensor`` can't deal with.
      >>> x = LazyTensor(torch.ones, 2, 3)
      >>> x[0, 0] = -x[0, 0]    # this will cause infinite recursion
      >>> y = x.clone()
      >>> x.add_(1) # modifying origin tensor after cloning leads to wrong materialization
      >>> z = x.tolist()
      >>> x.zeros_() # modifying origin tensor after cloning tolist is not allowed
      >>> nn.utils.weight_norm(self.conv, name="weight", dim=2) # applying weight norm on a lazy tensor is not allowed
  
  
      2. Cases that ``LazyTensor`` becomes eager (early materialization).
      >>> b = a[:, 2:]  # get a slice of a lazy tensor triggers early materialization
      >>> chunks = a.split(3)  # this also triggers early materialization
      >>> x.data = torch.rand(2, 3) # directly setting data of a lazy tensor triggers early materialization
class_docstr_tok: ["A","naive","implementation","of","LazyTensor","(","https",":","\/\/arxiv.org\/pdf\/2102.13267.pdf",")",".","Usage",":","1",".","Use","``","LazyTensor","``","instead","of","``","torch.Tensor","``",".",">",">",">","x","=","LazyTensor","(","torch.zeros",",","2",",","3",")",">",">",">","x","+=","1",">",">",">","y","=","x","*","x",">",">",">","y","=","y.cuda","(",")",".half","(",")",">",">",">","y","[","0",",","0","]","=","0",">",">",">","y","=","y.materialize","(",")","#","materialize","the","tensor",">",">",">","print","(","y",")","tensor","(","[","[","0.",",","1.",",","1",".","]",",","[","1.",",","1.",",","1",".","]","]",",","device='cuda:0","'",",","dtype=torch.float16",")","Warnings",":","1",".","Cases","that","``","LazyTensor","``","ca","n't","deal","with",".",">",">",">","x","=","LazyTensor","(","torch.ones",",","2",",","3",")",">",">",">","x","[","0",",","0","]","=","-x","[","0",",","0","]","#","this","will","cause","infinite","recursion",">",">",">","y","=","x.clone","(",")",">",">",">","x.add_","(","1",")","#","modifying","origin","tensor","after","cloning","leads","to","wrong","materialization",">",">",">","z","=","x.tolist","(",")",">",">",">","x.zeros_","(",")","#","modifying","origin","tensor","after","cloning","tolist","is","not","allowed",">",">",">","nn.utils.weight_norm","(","self.conv",",","name=","''","weight","''",",","dim=2",")","#","applying","weight","norm","on","a","lazy","tensor","is","not","allowed","2",".","Cases","that","``","LazyTensor","``","becomes","eager","(","early","materialization",")",".",">",">",">","b","=","a","[",":",",","2",":","]","#","get","a","slice","of","a","lazy","tensor","triggers","early","materialization",">",">",">","chunks","=","a.split","(","3",")","#","this","also","triggers","early","materialization",">",">",">","x.data","=","torch.rand","(","2",",","3",")","#","directly","setting","data","of","a","lazy","tensor","triggers","early","materialization"]
code: def detach(self) -> Tensor:
      return self
  
imports: from types import MethodType
  from typing import Callable, Optional, Union
  import torch
  import torch.nn
  from packaging import version
  from torch import Tensor
  from torch.nn import Parameter
  from torch.utils._pytree import tree_map
  from colossalai.logging import get_dist_logger
  from .construction import ConstructorManager
  from .pretrained import PretrainedManager
  import colossalai._analyzer._subclasses._meta_registration
label_desc: Use image node_id 15 for calling the LazyTensor obj's underlying member method code with example usage: obj.detach() and returns: self