code: def gaussian_focal_loss_with_pos_inds(
      pred: Tensor,
      gaussian_target: Tensor,
      pos_inds: Tensor,
      pos_labels: Tensor,
      alpha: float = 2.0,
      gamma: float = 4.0,
      pos_weight: float = 1.0,
      neg_weight: float = 1.0,
      reduction: str = "mean",
      avg_factor: Optional[Union[int, float]] = None,
  ) -> Tensor:
      """`Focal Loss <https://arxiv.org/abs/1708.02002>`_ for targets in gaussian
      distribution.
  
      Note: The index with a value of 1 in ``gaussian_target`` in the
      ``gaussian_focal_loss`` function is a positive sample, but in
      ``gaussian_focal_loss_with_pos_inds`` the positive sample is passed
      in through the ``pos_inds`` parameter.
  
      Args:
          pred (torch.Tensor): The prediction. The shape is (N, num_classes).
          gaussian_target (torch.Tensor): The learning target of the prediction
              in gaussian distribution. The shape is (N, num_classes).
          pos_inds (torch.Tensor): The positive sample index.
              The shape is (M, ).
          pos_labels (torch.Tensor): The label corresponding to the positive
              sample index. The shape is (M, ).
          alpha (float, optional): A balanced form for Focal Loss.
              Defaults to 2.0.
          gamma (float, optional): The gamma for calculating the modulating
              factor. Defaults to 4.0.
          pos_weight(float): Positive sample loss weight. Defaults to 1.0.
          neg_weight(float): Negative sample loss weight. Defaults to 1.0.
          reduction (str): Options are "none", "mean" and "sum".
              Defaults to 'mean`.
          avg_factor (int, float, optional): Average factor that is used to
              average the loss. Defaults to None.
      """
      eps = 1e-12
      neg_weights = (1 - gaussian_target).pow(gamma)
  
      pos_pred_pix = pred[pos_inds]
      pos_pred = pos_pred_pix.gather(1, pos_labels.unsqueeze(1))
      pos_loss = -(pos_pred + eps).log() * (1 - pos_pred).pow(alpha)
      pos_loss = weight_reduce_loss(
          pos_loss, None, reduction, avg_factor
      )
  
      neg_loss = -(1 - pred + eps).log() * pred.pow(alpha) * neg_weights
      neg_loss = weight_reduce_loss(
          neg_loss, None, reduction, avg_factor
      )
  
      return pos_weight * pos_loss + neg_weight * neg_loss
  
file_path: mmdetection/mmdet/models/losses/gaussian_focal_loss.py
imports: from typing import Optional, Union
  import torch.nn
  from torch import Tensor
  from mmdet.registry import MODELS
  from .utils import weight_reduce_loss, weighted_loss
label_desc: Use image node_id 2 for calling a global function with example usage: gaussian_focal_loss_with_pos_inds(pred, gaussian_target, pos_inds, pos_labels, alpha, gamma, pos_weight, neg_weight, reduction, avg_factor) and returns: unknown