feed-forward neural networks lastlywe need to define the batch size and the number of epochs required to train our model batch size refers to the number of samples within batch in mini-batch update one forward and backward pass for all the batches that cover all samples once is called an epoch finallywe pass all these constructs to our function to train our model let' take detailed look at the constructs within the function in our training functionwe define structure to train our network with the provided optimizerloss functionmodel objectand training data over batches for the defined number of epochs firstwe initiate our model for training mode with model train(setting the model object to train mode explicitly is essentialthe same would be essential while leveraging the model for evaluation-- explicitly setting the model to evaluate mode with model eval(this ensures that the model is aware of the time when it is expected to update the parameters and when to not in the preceding examplewe did not add the evaluation loop because it is tiny toy dataset in later examples with large datasetshoweverwe will use separate function for evaluation we will train the network over mini-batches the for loop divides the training data into batches with our defined size the training dataalong with the corresponding labelsis extracted for batch using the following codeinput_data x_train[ :min(x_train shape[ ], +batch_size)labels y_train[ :min(x_train shape[ ], +batch_size)we then need to set the gradients to zero before starting to do backpropagation using optimizer zero_grad(missing this step will accumulate the gradients on subsequent backward passes and lead to undesirable effects this behavior is by design in pytorch thenwe calculate the forward pass using output_data model(input_datathe forward pass is the execution of the forward(function in our class definition it connects the different layers we defined for the networkwhich finally outputs the prediction for each sample once we have the