Hi,
you can create a separate nn.Module which contains your loss functions and your learnable parameter, just like this:
class CostumLoss(nn.Module):
    def __init__(self):
        super().__init__()
        self.mse_fn = nn.MSELoss()
        self.ce_fn = nn.CrossEntropyLoss()
        self.gamma = nn.Parameter(torch.tensor([.5]))

    def forward(self, out, mse_target, ce_target):
        mse_loss = self.mse_fn(out, mse_target)
        ce_loss = self.ce_fn(out, ce_target)
        loss = mse_loss * self.gamma + ce_loss * (1 - self.gamma)
        return loss

For the optimization you can ether use a separate optimizer for your loss function or chain it with the model parameters:
import itertools

loss_fn = CostumLoss()
optim = optim.Adam(itertools.chain(model.parameters(), loss_fn.parameters()), lr=1e-3)

I think you could also declare gamma as a normal variable of type nn.Parameter outside of any Module, but i don’t know how you would ‘chain’ it with the other parameters, like i did above.