Jointly training with 2 Trainer

Hi I am reproducing a paper–When Image Denoising Meets High-Level Vision Tasks: A Deep Learning Approach-- It said that a Object Detection task and a Denoising task can train jointly

suppose I have 2 network :net_denoiser,net_detector

trainer_dt = Trainer(net_detector.collect_paramaters())
trainer_dn = Trainer(net_denoiser.collect_paramaters())

for(epoch):
  with autograde.record()
    dt_out = net_detector(imgs)
    dn_out = net_denoiser(imgs)
    dt_loss = dt_loss(detection_out,detection_label)
    dn_loss = dn_loss2(denoting_out,original image)
    total_loss = dt_loss+dn_loss
    total_loss.backward()
  trainer_dt.step()
  trainer_dn.step()

I am confused that:
am I right?
commonly a backward are followed by a trainer.step() operation.
I have never seen that a backward() operation followed by 2 trainer.step() operations.
If I have 2 or more backward() and trainer in a certain order(like GANs) . How to ensure that they can work properly ?
Thank you for your time and consideration.

Trainer is a helper class for optimizing a collection of parameters. You can use multiple Trainer objects if you intend to use a different optimizer or different optimization parameters for certain parameters of your network.

For the multi-task training case where you have multiple losses, you simply need to somehow combine your losses (which looks like you’re doing by adding the losses together) and then do a single backward() call on the combined loss and do a single trainer.step() call.