class_docstr: DataPipe that transfers each element yielded from the previous DataPipe
  to the given device. For MiniBatch, only the related attributes
  (automatically inferred) will be transferred by default. If you want to
  transfer any other attributes, indicate them in the ``extra_attrs``.
  
  Functional name: :obj:`copy_to`.
  
  When ``data`` has ``to`` method implemented, ``CopyTo`` will be equivalent
  to
  
  .. code:: python
  
     for data in datapipe:
         yield data.to(device)
  
  For :class:`~dgl.graphbolt.MiniBatch`, only a part of attributes will be
  transferred to accelerate the process by default:
  
  - When ``seed_nodes`` is not None and ``node_pairs`` is None, node related
  task is inferred. Only ``labels``, ``sampled_subgraphs``, ``node_features``
  and ``edge_features`` will be transferred.
  
  - When ``node_pairs`` is not None and ``seed_nodes`` is None, edge/link
  related task is inferred. Only ``labels``, ``compacted_node_pairs``,
  ``compacted_negative_srcs``, ``compacted_negative_dsts``,
  ``sampled_subgraphs``, ``node_features`` and ``edge_features`` will be
  transferred.
  
  - Otherwise, all attributes will be transferred.
  
  - If you want some other attributes to be transferred as well, please
  specify the name in the ``extra_attrs``. For instance, the following code
  will copy ``seed_nodes`` to the GPU as well:
  
  .. code:: python
  
     datapipe = datapipe.copy_to(device="cuda", extra_attrs=["seed_nodes"])
  
  Parameters
  ----------
  datapipe : DataPipe
      The DataPipe.
  device : torch.device
      The PyTorch CUDA device.
  extra_attrs: List[string]
      The extra attributes of the data in the DataPipe you want to be carried
      to the specific device. The attributes specified in the ``extra_attrs``
      will be transferred regardless of the task inferred. It could also be
      applied to classes other than :class:`~dgl.graphbolt.MiniBatch`.
class_docstr_tok: ["DataPipe","that","transfers","each","element","yielded","from","the","previous","DataPipe","to","the","given","device",".","For","MiniBatch",",","only","the","related","attributes","(","automatically","inferred",")","will","be","transferred","by","default",".","If","you","want","to","transfer","any","other","attributes",",","indicate","them","in","the","``","extra_attrs","``",".","Functional","name",":",":","obj",":","`","copy_to","`",".","When","``","data","``","has","``","to","``","method","implemented",",","``","CopyTo","``","will","be","equivalent","to","..","code",":",":","python","for","data","in","datapipe",":","yield","data.to","(","device",")","For",":","class",":","`","~dgl.graphbolt.MiniBatch","`",",","only","a","part","of","attributes","will","be","transferred","to","accelerate","the","process","by","default",":","-","When","``","seed_nodes","``","is","not","None","and","``","node_pairs","``","is","None",",","node","related","task","is","inferred",".","Only","``","labels","``",",","``","sampled_subgraphs","``",",","``","node_features","``","and","``","edge_features","``","will","be","transferred",".","-","When","``","node_pairs","``","is","not","None","and","``","seed_nodes","``","is","None",",","edge\/link","related","task","is","inferred",".","Only","``","labels","``",",","``","compacted_node_pairs","``",",","``","compacted_negative_srcs","``",",","``","compacted_negative_dsts","``",",","``","sampled_subgraphs","``",",","``","node_features","``","and","``","edge_features","``","will","be","transferred",".","-","Otherwise",",","all","attributes","will","be","transferred",".","-","If","you","want","some","other","attributes","to","be","transferred","as","well",",","please","specify","the","name","in","the","``","extra_attrs","``",".","For","instance",",","the","following","code","will","copy","``","seed_nodes","``","to","the","GPU","as","well",":","..","code",":",":","python","datapipe","=","datapipe.copy_to","(","device=","''","cuda","''",",","extra_attrs=","[","``","seed_nodes","''","]",")","Parameters","--","--","--","--","--","datapipe",":","DataPipe","The","DataPipe",".","device",":","torch.device","The","PyTorch","CUDA","device",".","extra_attrs",":","List","[","string","]","The","extra","attributes","of","the","data","in","the","DataPipe","you","want","to","be","carried","to","the","specific","device",".","The","attributes","specified","in","the","``","extra_attrs","``","will","be","transferred","regardless","of","the","task","inferred",".","It","could","also","be","applied","to","classes","other","than",":","class",":","`","~dgl.graphbolt.MiniBatch","`","."]
code: def __init__(self, datapipe, device, extra_attrs=None):
      super().__init__()
      self.datapipe = datapipe
      self.device = device
      self.extra_attrs = extra_attrs
  
file_path: dgl/python/dgl/graphbolt/base.py
imports: from dataclasses import dataclass
  import torch
  from torch.utils.data import functional_datapipe
  from torchdata.datapipes.iter import IterDataPipe
  from ..utils import recursive_apply
label_desc: Use image node_id 1 to create a new CopyTo object from inherited base classes: IterDataPipe with example: obj = CopyTo(datapipe, device, extra_attrs)