training deep leaning models #compute penalty to be added with loss for in model parameters() _loss _loss abs(sum(#add penalty to loss loss loss lambda_l _loss #backpropogate loss backward(#update weights optimizer step(train_loss +loss item(input_data size( loss_across_epochs append(train_loss/x_train size( )if epoch% = print("epoch{loss:{ }format(epochtrain_loss/x_train size( )return(loss_across_epochsthe preceding function loops over batches for the defined number of epochs and trains our neural network you are already familiar with this function (refer to )the only new addition to the function is the calculation of an penalty when we use regularization the lambda_l variable is hyperparameter that we can tune to control the effect if the regularizer let' now define function that can be used to plot the loss over epochsroc curve for the training and validation datasetsand evaluate the model for key metrics of interest because this is classification use casewe will compute accuracyprecisionand recall using the functions we imported earlier from sklearn listing - demonstrates the boilerplate code for evaluating model