import torch


def to_cuda(elements):
    """
    Transfers elements to GPU memory, if a nvidia- GPU is available.
    Args:
        elements: A list or a single pytorch module.
    Returns:
        The same list transferred to GPU memory
    """
    #print(torch.cuda.is_available())
    
    if torch.cuda.is_available(): # Checks if a GPU is available for pytorch
        if isinstance(elements, (list, tuple)):
            return [x.cuda() for x in elements] # Transfer each index of the list to GPU memory
        return elements.cuda()
    return elements