I would like to use different loss functions for different images which are in the same batch. For example, lets say my batch size is 8, and for the images 1,2 and 8 I am going to use Loss 1, and for the rest of the images I am going to use Loss 2. Assume that both are cross-entropy losses. Is there any way to easily implement it using PyTorch? In other words I have to select which loss should be used for each of the images in a particular batch.