def METHOD_NAME(variables):
    if isinstance(variables, list):
        variables_shape = [i.pytorch.shape for i in variables]
        device = torch.device(str(variables[0].pytorch.device))
    elif hasattr(variables, "pytorch"):
        variables_shape = [i.shape for i in variables.pytorch]
        device = torch.device(str(variables.pytorch[0].device))
    else:
        assert False
    grads = [
        random_tensor(len(shape), *shape, requires_grad=True).to(device)
        for shape in variables_shape
    ]
    return grads