Loss formulation which involves model parameters

Giving a dummy loss formulation here :-
Let L = A*BCELoss(output, ground_truth) + B where A, B are model parameters.
How would one proceed to define the loss function and model for this loss formulation.

Is the question about how to make A and B learnable parameters?
In that case, you could add A and B to your model class definition as nn.Parameter and then compute the loss as

loss = model.A * bce(output, gt) + model.B