If you use trainable weights on your last loss, the training would push them to a negative value, as it’s yielding the minimal loss, wouldn’t it?
Anyway, you could define a new parameter as:
weight = nn.Parameter(torch.tensor(1))

and push it to the optimizer with all other parameters:
optimizer = torch.optim.SGD(list(model.parameters()) + [weight], lr=1e-3)