from typing import Dict
import torch


def dictionary_to_device(dictionary: Dict, device: torch.device):
    """Move dictionary values to a torch device, if they support it.

    :param dictionary: Dictionary, whose values are to be moved to the torch device.
    :param device: torch device
    :return: Dictionary, with values moved to torch device (if they support it).
    """
    for key, value in dictionary.items():
        if callable(getattr(value, "to", None)):
            dictionary[key] = value.to(device)

    return dictionary