def make_train_loader(img_dim, shuffle=10000, batch_size=FLAGS.batch_size):
    num_dataset_instances = (xm.xrt_world_size() * FLAGS.num_workers)
    epoch_size = (trainsize // num_dataset_instances)
    image_transform = transforms.Compose([transforms.RandomResizedCrop(img_dim), transforms.RandomHorizontalFlip(), transforms.ToTensor(), normalize])
    dataset = wds.WebDataset('pipe:cat /mnt/disks/dataset/webdataset/shards-640/imagenet-train-{000000..000639}.tar', splitter=my_worker_splitter, nodesplitter=my_node_splitter, shardshuffle=True, length=epoch_size).shuffle(shuffle).decode('pil').to_tuple('ppm;jpg;jpeg;png', 'cls').map_tuple(image_transform, identity).batched(batch_size, partial=True)
    loader = torch.utils.data.DataLoader(dataset, batch_size=None, shuffle=False, drop_last=False, num_workers=FLAGS.num_workers)
    return loader
def make_train_loader(img_dim, shuffle=10000, batch_size=FLAGS.batch_size):
    num_dataset_instances = (xm.xrt_world_size() * FLAGS.num_workers)
    epoch_size = (trainsize // num_dataset_instances)
    image_transform = transforms.Compose([transforms.RandomResizedCrop(img_dim), transforms.RandomHorizontalFlip(), transforms.ToTensor(), normalize])
    dataset = wds.WebDataset('pipe:cat /mnt/disks/dataset/webdataset/shards-640/imagenet-train-{000000..000639}.tar', splitter=my_worker_splitter, nodesplitter=my_node_splitter, shardshuffle=True, length=epoch_size).shuffle(shuffle).decode('pil').to_tuple('ppm;jpg;jpeg;png', 'cls').map_tuple(image_transform, identity).batched(batch_size, partial=True)
    loader = torch.utils.data.DataLoader(dataset, batch_size=None, shuffle=False, drop_last=False, num_workers=FLAGS.num_workers)
    return loader