class_docstr: GPU cached feature wrapping a fallback feature.
  
  Places the GPU cache to torch.cuda.current_device().
  
  Parameters
  ----------
  fallback_feature : Feature
      The fallback feature.
  cache_size : int
      The capacity of the GPU cache, the number of features to store.
  
  Examples
  --------
  >>> import torch
  >>> from dgl import graphbolt as gb
  >>> torch_feat = torch.arange(10).reshape(2, -1).to("cuda")
  >>> cache_size = 5
  >>> fallback_feature = gb.TorchBasedFeature(torch_feat)
  >>> feature = gb.GPUCachedFeature(fallback_feature, cache_size)
  >>> feature.read()
  tensor([[0, 1, 2, 3, 4],
          [5, 6, 7, 8, 9]], device='cuda:0')
  >>> feature.read(torch.tensor([0]).to("cuda"))
  tensor([[0, 1, 2, 3, 4]], device='cuda:0')
  >>> feature.update(torch.tensor([[1 for _ in range(5)]]).to("cuda"),
  ...                torch.tensor([1]).to("cuda"))
  >>> feature.read(torch.tensor([0, 1]).to("cuda"))
  tensor([[0, 1, 2, 3, 4],
          [1, 1, 1, 1, 1]], device='cuda:0')
  >>> feature.size()
  torch.Size([5])
docstr: Read the feature by index.
  
  The returned tensor is always in GPU memory, no matter whether the
  fallback feature is in memory or on disk.
  
  Parameters
  ----------
  ids : torch.Tensor, optional
      The index of the feature. If specified, only the specified indices
      of the feature are read. If None, the entire feature is returned.
  
  Returns
  -------
  torch.Tensor
      The read feature.
docstr_tok: ["Read","the","feature","by","index",".","The","returned","tensor","is","always","in","GPU","memory",",","no","matter","whether","the","fallback","feature","is","in","memory","or","on","disk",".","Parameters","--","--","--","--","--","ids",":","torch.Tensor",",","optional","The","index","of","the","feature",".","If","specified",",","only","the","specified","indices","of","the","feature","are","read",".","If","None",",","the","entire","feature","is","returned",".","Returns","--","--","--","-","torch.Tensor","The","read","feature","."]
code: def read(self, ids: torch.Tensor = None):
      """Read the feature by index.
  
      The returned tensor is always in GPU memory, no matter whether the
      fallback feature is in memory or on disk.
  
      Parameters
      ----------
      ids : torch.Tensor, optional
          The index of the feature. If specified, only the specified indices
          of the feature are read. If None, the entire feature is returned.
  
      Returns
      -------
      torch.Tensor
          The read feature.
      """
      if ids is None:
          return self._fallback_feature.read().to("cuda")
      keys = ids.to("cuda")
      values, missing_index, missing_keys = self._feature.query(keys)
      missing_values = self._fallback_feature.read(missing_keys).to(
          "cuda"
      )
      missing_values = missing_values.reshape(self.flat_shape)
      values = values.to(missing_values.dtype)
      values[missing_index] = missing_values
      self._feature.replace(missing_keys, missing_values)
      return torch.reshape(values, self.item_shape)
  
file_path: dgl/python/dgl/graphbolt/impl/gpu_cached_feature.py
imports: import torch
  from dgl.cuda import GPUCache
  from ..feature_store import Feature
label_desc: Use image node_id 2 for calling the GPUCachedFeature obj's underlying member method code with example usage: obj.read(ids) and returns: torch, self