Unfortunately, I cannot give any advice besides explaining that the currenty used model output and target shapes don’t fit together and you won’t be able to calculate the loss using a “standard” loss function.
To further help you would need to explain how the loss should be calculated given these shapes.