I think dataloader can serve as it is stream based loading, load objects one by one using next(iterator)

num_epochs=20
class partA(Dataset):
def init(self):
# data loading
xy = np.loadtxt(‘file.csv’,delimiter=",",dtype=np.float32,skiprows=1)
    self.x = torch.from_numpy(xy[:,1:])
    self.y = torch.from_numpy(xy[:,[0]])
    
    self.n_samples = xy.shape[0]

def __getitem__(self,index):
    # dataset[0]
    return self.x[index], self.y[index]
    
def __len__(self):
    return self.n_samples

dataset= partA()
dataloader= DataLoader(dataset=dataset, batch_size=40,shuffle=True,num_workers=2)
for epoch in range(num_epochs):
for i, (inputs,labels) in enumerate(dataloader):
# forward backward , update weights here
if (i+1) % 10 ==0:
print(f’epoch {epoch+1}/{num_epochs}, step{i+1}/{n_iterations},inputs {inputs.shape}’

Apologies , if i misunderstood your question. I am very naive in pytorch