# How to do a batch trainning of Pytorch model without using Dataloader?

I am doing a time series data training. I have to pad 0s to the data so the sequences have the same length. Because of 0s are padded, I have to mask them during the training, for Keras, it is simply done by applying a Masking layer.

However, Pytorch requires much more steps. The pack_padded_sequence allows us to mask the 0s but the function requires me to place all the different length sequences in one list. I was stuck here because I always put all the aligned sequences to Dataloader and run the training. How can I run the batch training without the Dataloader.

## A sample code would be the following

X = [[[1,2,3],[2,3,4]],[[1,2,4]],[[5,6,4]]] #  a list of 2d arrays.
y = [0,1,2]

model = model(ninp=40,num_layers=num_layers,class_num=class_num,nhid=nhid)
#The desired input shape is (X,60,40) (batch,length,features)
loss_function = nn.CrossEntropyLoss()

for x,y in zip(X_train,y_train):
# x to be a small batch

As it is shown that Dataloader is replaced with zip(). Am I on the right track?