Keras Data Generator to Pytorch Data Generator

Hi ,

How can I change a Keras Data Generator to a pytorch data Generator? Just curious whether there are any shortcuts or not. I added one example below.

In Keras case, we usually use Keras generators to fit the model as follows.

model.fit_generator(generator=train_data, steps_per_epoch=len(train_data), validation_data=validation_data, validation_steps=len(validation_data), epochs=epochs,verbose=1,callbacks=callbacks)