Putting loss inside the model definition? For example, see Trainable Variable in Loss Function and Matrix Multiplication