It depends on your use case and how you would like to fine tune the basemodel.
Currently both losses would create gradients in the parameters or basemodel, since these parameters were used to compute the losses. If you only want to create the gradients of loss_basemodel w.r.t to the parameters of basemodel, you would have to .detach() output_base_model before feeding it to classifier.
Note that there are minor issues (such as using for param in model.basemodel() instead of for param in basemodel.parameters()) but I assume these are copy-paste errors.
Also, if you are iterating the parameters, i will not reflect the layers, since some modules have more than a single parameter (often weight and bias).