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: Update the feature store.
  
  Parameters
  ----------
  value : torch.Tensor
      The updated value of the feature.
  ids : torch.Tensor, optional
      The indices of the feature to update. If specified, only the
      specified indices of the feature will be updated. For the feature,
      the `ids[i]` row is updated to `value[i]`. So the indices and value
      must have the same length. If None, the entire feature will be
      updated.
docstr_tok: ["Update","the","feature","store",".","Parameters","--","--","--","--","--","value",":","torch.Tensor","The","updated","value","of","the","feature",".","ids",":","torch.Tensor",",","optional","The","indices","of","the","feature","to","update",".","If","specified",",","only","the","specified","indices","of","the","feature","will","be","updated",".","For","the","feature",",","the","`","ids","[","i","]","`","row","is","updated","to","`","value","[","i","]","`",".","So","the","indices","and","value","must","have","the","same","length",".","If","None",",","the","entire","feature","will","be","updated","."]
code: def update(self, value: torch.Tensor, ids: torch.Tensor = None):
      """Update the feature store.
  
      Parameters
      ----------
      value : torch.Tensor
          The updated value of the feature.
      ids : torch.Tensor, optional
          The indices of the feature to update. If specified, only the
          specified indices of the feature will be updated. For the feature,
          the `ids[i]` row is updated to `value[i]`. So the indices and value
          must have the same length. If None, the entire feature will be
          updated.
      """
      if ids is None:
          assert self.size() == value.size()[1:], (
              f"ids is None, so the entire feature will be updated. "
              f"But the size of the feature is {self.size()}, "
              f"while the size of the value is {value.size()[1:]}."
          )
          self._tensor = value
      else:
          assert ids.shape[0] == value.shape[0], (
              f"ids and value must have the same length, "
              f"but got {ids.shape[0]} and {value.shape[0]}."
          )
          assert self.size() == value.size()[1:], (
              f"The size of the feature is {self.size()}, "
              f"while the size of the value is {value.size()[1:]}."
          )
          if self._tensor.is_pinned() and value.is_cuda and ids.is_cuda:
              raise NotImplementedError(
                  "Update the feature on pinned CPU memory by GPU is not "
                  "supported yet."
              )
          self._tensor[ids] = value
  
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 4 for calling the TorchBasedFeature obj's underlying member method code with example usage: obj.update(value, ids) without return types