import torch


def get_random_tensor(size, dtype, use_cuda):
    """Returns a random tensor of given type and size

    Args:
        size (int): Tensor size (number of elements)
        dtype (:obj:`torch.dtype`): One of `torch.float16` and `torch.flaot32`
        use_cuda (bool): Return CUDA tensor

    Returns:

    """
    tensor = torch.rand(size).to(dtype=dtype)
    if use_cuda:
        tensor = tensor.cuda()
    return tensor