I assume the flow output would be encoded with some real values?
In the easiest use case, you would use nn.MSELoss, but I guess the latest state of the art optical flow models might use a custom loss function.
Are you trying to create a new approach or recreate a paper implementation?