Thank you for fast reply.
I did exactly like it’s shown in: https://github.com/pytorch/vision/blob/master/references/detection/engine.py (in train_one_epoch function):

    loss_dict = model(images, targets)

    losses = sum(loss for loss in loss_dict.values())

    ...

    optimizer.zero_grad()
    losses.backward()
    optimizer.step()