class_docstr: A wrapper of pytorch based feature.
  
  Initialize a torch based feature store by a torch feature.
  Note that the feature can be either in memory or on disk.
  
  Parameters
  ----------
  torch_feature : torch.Tensor
      The torch feature.
      Note that the dimension of the tensor should be greater than 1.
  
  Examples
  --------
  >>> import torch
  >>> from dgl import graphbolt as gb
  
  1. The feature is in memory.
  
  >>> torch_feat = torch.arange(10).reshape(2, -1)
  >>> feature = gb.TorchBasedFeature(torch_feat)
  >>> feature.read()
  tensor([[0, 1, 2, 3, 4],
          [5, 6, 7, 8, 9]])
  >>> feature.read(torch.tensor([0]))
  tensor([[0, 1, 2, 3, 4]])
  >>> feature.update(torch.tensor([[1 for _ in range(5)]]),
  ...                      torch.tensor([1]))
  >>> feature.read(torch.tensor([0, 1]))
  tensor([[0, 1, 2, 3, 4],
          [1, 1, 1, 1, 1]])
  >>> feature.size()
  torch.Size([5])
  
  2. The feature is on disk.
  
  >>> import numpy as np
  >>> arr = np.array([[1, 2], [3, 4]])
  >>> np.save("/tmp/arr.npy", arr)
  >>> torch_feat = torch.from_numpy(np.load("/tmp/arr.npy", mmap_mode="r+"))
  >>> feature = gb.TorchBasedFeature(torch_feat)
  >>> feature.read()
  tensor([[1, 2],
          [3, 4]])
  >>> feature.read(torch.tensor([0]))
  tensor([[1, 2]])
  
  3. Pinned CPU feature.
  >>> torch_feat = torch.arange(10).reshape(2, -1).pin_memory()
  >>> feature = gb.TorchBasedFeature(torch_feat)
  >>> feature.read().device
  device(type='cuda', index=0)
  >>> feature.read(torch.tensor([0]).cuda()).device
  device(type='cuda', index=0)
class_docstr_tok: ["A","wrapper","of","pytorch","based","feature",".","Initialize","a","torch","based","feature","store","by","a","torch","feature",".","Note","that","the","feature","can","be","either","in","memory","or","on","disk",".","Parameters","--","--","--","--","--","torch_feature",":","torch.Tensor","The","torch","feature",".","Note","that","the","dimension","of","the","tensor","should","be","greater","than","1",".","Examples","--","--","--","--",">",">",">","import","torch",">",">",">","from","dgl","import","graphbolt","as","gb","1",".","The","feature","is","in","memory",".",">",">",">","torch_feat","=","torch.arange","(","10",")",".reshape","(","2",",","-1",")",">",">",">","feature","=","gb.TorchBasedFeature","(","torch_feat",")",">",">",">","feature.read","(",")","tensor","(","[","[","0",",","1",",","2",",","3",",","4","]",",","[","5",",","6",",","7",",","8",",","9","]","]",")",">",">",">","feature.read","(","torch.tensor","(","[","0","]",")",")","tensor","(","[","[","0",",","1",",","2",",","3",",","4","]","]",")",">",">",">","feature.update","(","torch.tensor","(","[","[","1","for","_","in","range","(","5",")","]","]",")",",","...","torch.tensor","(","[","1","]",")",")",">",">",">","feature.read","(","torch.tensor","(","[","0",",","1","]",")",")","tensor","(","[","[","0",",","1",",","2",",","3",",","4","]",",","[","1",",","1",",","1",",","1",",","1","]","]",")",">",">",">","feature.size","(",")","torch.Size","(","[","5","]",")","2",".","The","feature","is","on","disk",".",">",">",">","import","numpy","as","np",">",">",">","arr","=","np.array","(","[","[","1",",","2","]",",","[","3",",","4","]","]",")",">",">",">","np.save","(","``","\/tmp\/arr.npy","''",",","arr",")",">",">",">","torch_feat","=","torch.from_numpy","(","np.load","(","``","\/tmp\/arr.npy","''",",","mmap_mode=","''","r+","''",")",")",">",">",">","feature","=","gb.TorchBasedFeature","(","torch_feat",")",">",">",">","feature.read","(",")","tensor","(","[","[","1",",","2","]",",","[","3",",","4","]","]",")",">",">",">","feature.read","(","torch.tensor","(","[","0","]",")",")","tensor","(","[","[","1",",","2","]","]",")","3",".","Pinned","CPU","feature",".",">",">",">","torch_feat","=","torch.arange","(","10",")",".reshape","(","2",",","-1",")",".pin_memory","(",")",">",">",">","feature","=","gb.TorchBasedFeature","(","torch_feat",")",">",">",">","feature.read","(",")",".device","device","(","type='cuda","'",",","index=0",")",">",">",">","feature.read","(","torch.tensor","(","[","0","]",")",".cuda","(",")",")",".device","device","(","type='cuda","'",",","index=0",")"]
docstr: In-place operation to copy the feature to pinned memory.
docstr_tok: ["In-place","operation","to","copy","the","feature","to","pinned","memory","."]
code: def pin_memory_(self):
      """In-place operation to copy the feature to pinned memory."""
      self._tensor = self._tensor.pin_memory()
  
imports: import copy
  import textwrap
  from typing import Dict, List
  import numpy
  import torch
  from ..feature_store import Feature
  from .basic_feature_store import BasicFeatureStore
  from .ondisk_metadata import OnDiskFeatureData
label_desc: Use image node_id 6 for calling the TorchBasedFeature obj's underlying member method code with example usage: obj.pin_memory_() without return types