import json
import torch


def read_batches_from_disk(input_file_name):
    """Reads batches previously stored to disk and loads them in memory."""
    with open(input_file_name, 'r') as input:
        batches = json.load(input)
    for batch in batches:
        batch['x'] = torch.tensor(batch['x'])
        batch['y'] = torch.tensor(batch['y'])
    return batches