I created the dataset in this way and then passed it to the loader
import os
import sys
import pickle
from skimage import io
import matplotlib.pyplot as plt
import numpy
import torch
from torch.utils.data import Dataset
class CIFAR100Train(Dataset):
“”“cifar100 test dataset, derived from
torch.utils.data.DataSet
“””
def __init__(self, path, transform=None):
    #if transform is given, we transoform data using
    with open(os.path.join(path, 'train'), 'rb') as cifar100:
        self.data = pickle.load(cifar100, encoding='bytes')
    self.transform = transform
    
def __len__(self):
    return len(self.data['coarse_labels'.encode()])

def __getitem__(self, index):
    label = self.data['coarse_labels'.encode()][index]
    print(label)
    r = self.data['data'.encode()][index, :1024].reshape(32, 32)
    g = self.data['data'.encode()][index, 1024:2048].reshape(32, 32)
    b = self.data['data'.encode()][index, 2048:].reshape(32, 32)
    image = numpy.dstack((r, g, b))

    if self.transform:
        image = self.transform(image)
    return label, image

this is the piece of the train
for  i ,(inputs,coarse_labels) in enumerate(tqdm(data_loader, desc=f’EPOCH: {epoch+1}/{args.epochs}’)):
inputs=inputs.to(device)
#coarse_label_names=coarse_label_names.to(device)
#print(coarse_labecl_name)
coarse_labels = coarse_labels.to(device)
                # train GAN
                if split == 'train':
                    loss_gan_dict = gan_trainer.forward_batch(inputs, coarse_labels)
                    fake_images = loss_gan_dict['generated_img'] # 64 x 3 x 32 x 32

                #if split == 'test':
                   
                        



                step = (epoch * len(data_loader)) + i

                # log train
                if split == 'train':
                    saver.log_loss("Discriminator/Loss", loss_gan_dict['discriminator'], step)
                    saver.log_loss("Discriminator/Real_Right_Loss", loss_gan_dict['discriminator_real_right'], step)
                    saver.log_loss("Discriminator/Real_Wrong_Loss", loss_gan_dict['discriminator_real_wrong'], step)
                    saver.log_loss("Discriminator/Fake_Loss", loss_gan_dict['discriminator_fake'], step)
                    saver.log_loss("Generator/Loss", loss_gan_dict['generator'], step)
                    saver.log_loss("Generator/Loss Fake", loss_gan_dict['generator_loss_fake'], step)

                    
            #evaluate generation of images putting generator in eval mode
            g_net.eval()
            z_in = torch.randn(len(coarse_labels), 100).to(device)
            for i in range(0, 20):
                label_vector = torch.ones(80, dtype=torch.int64).to(device)
                label_vector = label_vector*i
                z_in = torch.randn(len(label_vector), 100).to(device)
                results, _ = g_net(z_in, label_vector)
                saver.log_images("Fake Images 80/"+classes[i], epoch, results)

            # Generate 8 samples for each class with fixed noise
            labels_20 = torch.arange(0,20).to(device)
            labels_20 = labels_100.repeat(8)
            z_fixed = torch.randn(len(labels_20), 100).to(device)
            samples_20, _ = g_net(z_in, labels_20)
            saver.log_images("Fake Images/eval_20_fixed_noise", epoch, samples_20)

            # reset net to train mode
            g_net.train()