We have already defined loss functions as PyTorch layers. So, let's create the loss layers for different style losses and content losses. The following code defines the function:
loss_fns = [StyleLoss()] * len(style_layers) + [nn.MSELoss()] * len(content_layers)
The loss_fns is a list containing a bunch of style loss objects and content loss objects based on the lengths of the arrays created.