​import torch ​ # Define the model model = CustomizedModel() # Define the loss function loss_fn = torch.nn.L1Loss() # Define optimizer optimizer = torch.optim.SGD(params = model.parameters(), lr = 0.01, momentum = 0.9) ​ epoches = 10 for epoch in range(epoches): # Step 1: Setting the Model to Training Mode: model.train() # Step 2: Forward Pass - Making Predictions y_pred = model(X_train) # Step 3: Calculating the Loss loss = loss_fn(y_pred, y_train) # Step 4: Backpropagation - Calculating Gradients optimizer.zero_grad() # clears old gradients loss.backward() # performs backpropagation to compute the gradients of the loss w.r.t model parameters # Step 5: Gradient Descent - Updating Parameters optimizer.step()