code: def collect_grad(self, pred, target, weight):
      prob = torch.sigmoid(pred)
      grad = target * (prob - 1) + (1 - target) * prob
      grad = torch.abs(grad)
  
      # do not collect grad for objectiveness branch [:-1]
      pos_grad = torch.sum(grad * target * weight, dim=0)[:-1]
      neg_grad = torch.sum(grad * (1 - target) * weight, dim=0)[:-1]
  
      if self.use_distributed:
          dist.all_reduce(pos_grad)
          dist.all_reduce(neg_grad)
  
      self.pos_grad += pos_grad
      self.neg_grad += neg_grad
      self.pos_neg = self.pos_grad / (self.neg_grad + 1e-10)
  
file_path: mmdetection/mmdet/models/losses/eqlv2_loss.py
imports: import logging
  from functools import partial
  from typing import Optional
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
  from mmengine.logging import print_log
  from torch import Tensor
  from mmdet.registry import MODELS
label_desc: Use image node_id 5 for calling the EQLV2Loss obj's underlying member method code with example usage: obj.collect_grad(pred, target, weight) without return types