import io
import torch


def torch_load_cpu(data):
    """Loads a serialized pytorch object from torch_get_raw() with CPU
    placement"""
    f = io.BytesIO(data)
    ret = torch.load(f, map_location=lambda storage, loc: storage)
    f.close()
    torch.set_num_threads(1)
    return ret