def to(
        self, device: torch.device, non_blocking=False
    ):  # pylint: disable=invalid-name
        """Copy `MiniBatch` to the specified device using reflection."""

        copy_fn = lambda x: apply_to(x, device, non_blocking=non_blocking)

        transfer_attrs = get_nonproperty_attributes(self)

        for attr in transfer_attrs:
            # Only copy member variables.
            setattr(self, attr, recursive_apply(getattr(self, attr), copy_fn))

        return self
Copy `MiniBatch` to the specified device using reflection.
python/dgl/graphbolt/minibatch.py