def check_device(data, device):
    """Check if data is on the target device.

    Parameters
    ----------
    data : Tensor or dict[str, Tensor]
    device: Backend device.

    Returns
    -------
    Bool: True if the data is on the target device.
    """
    if isinstance(data, dict):
        for v in data.values():
            if v.device != device:
                return False
    elif data.device != device:
        return False
    return True
Check if data is on the target device.

    Parameters
    ----------
    data : Tensor or dict[str, Tensor]
    device: Backend device.

    Returns
    -------
    Bool: True if the data is on the target device.
    
python/dgl/utils/checks.py