class_docstr: A composite data class for data structure in the graphbolt.
  
  It is designed to facilitate the exchange of data among different components
  involved in processing data. The purpose of this class is to unify the
  representation of input and output data across different stages, ensuring
  consistency and ease of use throughout the loading process.
class_docstr_tok: ["A","composite","data","class","for","data","structure","in","the","graphbolt",".","It","is","designed","to","facilitate","the","exchange","of","data","among","different","components","involved","in","processing","data",".","The","purpose","of","this","class","is","to","unify","the","representation","of","input","and","output","data","across","different","stages",",","ensuring","consistency","and","ease","of","use","throughout","the","loading","process","."]
docstr: Copy `MiniBatch` to the specified device using reflection.
docstr_tok: ["Copy","`","MiniBatch","`","to","the","specified","device","using","reflection","."]
code: def to(self, device: torch.device):  # pylint: disable=invalid-name
      """Copy `MiniBatch` to the specified device using reflection."""
  
      def _to(x, device):
          return x.to(device) if hasattr(x, "to") else x
  
      def apply_to(x, device):
          return recursive_apply(x, lambda x: _to(x, device))
  
      if (
          self.seed_nodes is not None
          and self.compacted_node_pairs is None
      ):
          # Node related tasks.
          transfer_attrs = [
              "labels",
              "sampled_subgraphs",
              "node_features",
              "edge_features",
          ]
          if self.labels is None:
              # Layerwise inference
              transfer_attrs.append("seed_nodes")
      elif (
          self.seed_nodes is None
          and self.compacted_node_pairs is not None
      ):
          # Link/edge related tasks.
          transfer_attrs = [
              "labels",
              "compacted_node_pairs",
              "compacted_negative_srcs",
              "compacted_negative_dsts",
              "sampled_subgraphs",
              "node_features",
              "edge_features",
          ]
      else:
          # Otherwise copy all the attributes to the device.
          transfer_attrs = get_attributes(self)
  
      for attr in transfer_attrs:
          # Only copy member variables.
          try:
              # For read-only attributes such as blocks and
              # node_pairs_with_labels, setattr will throw an AttributeError.
              # We catch these exceptions and skip those attributes.
              setattr(self, attr, apply_to(getattr(self, attr), device))
          except AttributeError:
              continue
  
      return self
  
imports: from dataclasses import dataclass
  from typing import Dict, List, Tuple, Union
  import torch
  import dgl
  from dgl.utils import recursive_apply
  from .base import etype_str_to_tuple
  from .internal import get_attributes
  from .sampled_subgraph import SampledSubgraph
label_desc: Use image node_id 11 for calling the MiniBatch obj's underlying member method code with example usage: obj.to(device) and returns: self, unknown, recursive_apply