def backward(self, loss, update_master_grads=False):
        """
        Computes the sum of gradients of the given tensor w.r.t. graph leaves.
        Compared to :func:`fairseq.optim.FairseqOptimizer.backward`, this function
        additionally dynamically scales the loss to avoid gradient underflow.
        """
        if self.scaler is not None:
            loss = loss * self.scaler.loss_scale
        loss.backward()
        self._needs_sync = True
        if update_master_grads:
            self.update_master_grads()

        Computes the sum of gradients of the given tensor w.r.t. graph leaves.
        Compared to :func:`fairseq.optim.FairseqOptimizer.backward`, this function
        additionally dynamically scales the loss to avoid gradient underflow.
        
EVA-CLIP/rei/training/fp16.py