class_docstr: Heatmap Focal Loss layer
class_docstr_tok: ["Heatmap","Focal","Loss","layer"]
code: def forward(self, pred, gt):
      pos_inds = gt.eq(1).float()
      neg_inds = gt.lt(1).float()
  
      pred = _sigmoid(pred)
      neg_weights = torch.pow(1 - gt, self.beta)
  
      pos_loss = (
          torch.log(pred) * torch.pow(1 - pred, self.alpha) * pos_inds
      )
      neg_loss = (
          torch.log(1 - pred)
          * torch.pow(pred, self.alpha)
          * neg_weights
          * neg_inds
      )
  
      num_pos = pos_inds.float().sum()
      pos_loss = pos_loss.sum()
      neg_loss = neg_loss.sum()
  
      if num_pos == 0:
          return -neg_loss
      else:
          return -(pos_loss + neg_loss) / num_pos
  
file_path: gluon-cv/gluoncv/torch/nn/keypoint_loss.py
imports: import torch
  import torch.nn
label_desc: Use image node_id 2 for calling the HMFocalLoss obj's underlying member method code with example usage: obj.forward(pred, gt) and returns: unknown, unknown