class_docstr: FocalLossCost.
  
  Args:
      alpha (Union[float, int]): focal_loss alpha. Defaults to 0.25.
      gamma (Union[float, int]): focal_loss gamma. Defaults to 2.
      eps (float): Defaults to 1e-12.
      binary_input (bool): Whether the input is binary. Currently,
          binary_input = True is for masks input, binary_input = False
          is for label input. Defaults to False.
      weight (Union[float, int]): Cost weight. Defaults to 1.
class_docstr_tok: ["FocalLossCost",".","Args",":","alpha","(","Union","[","float",",","int","]",")",":","focal_loss","alpha",".","Defaults","to","0.25.","gamma","(","Union","[","float",",","int","]",")",":","focal_loss","gamma",".","Defaults","to","2.","eps","(","float",")",":","Defaults","to","1e-12",".","binary_input","(","bool",")",":","Whether","the","input","is","binary",".","Currently",",","binary_input","=","True","is","for","masks","input",",","binary_input","=","False","is","for","label","input",".","Defaults","to","False",".","weight","(","Union","[","float",",","int","]",")",":","Cost","weight",".","Defaults","to","1","."]
docstr: Args:
      cls_pred (Tensor): Predicted classification logits.
          in shape (num_queries, d1, ..., dn), dtype=torch.float32.
      gt_labels (Tensor): Ground truth in shape (num_gt, d1, ..., dn),
          dtype=torch.long. Labels should be binary.
  
  Returns:
      Tensor: Focal cost matrix with weight in shape                (num_queries, num_gt).
code: def _mask_focal_loss_cost(self, cls_pred, gt_labels) -> Tensor:
      """
          Args:
              cls_pred (Tensor): Predicted classification logits.
                  in shape (num_queries, d1, ..., dn), dtype=torch.float32.
              gt_labels (Tensor): Ground truth in shape (num_gt, d1, ..., dn),
                  dtype=torch.long. Labels should be binary.
  
          Returns:
              Tensor: Focal cost matrix with weight in shape\
                  (num_queries, num_gt).
          """
      cls_pred = cls_pred.flatten(1)
      gt_labels = gt_labels.flatten(1).float()
      n = cls_pred.shape[1]
      cls_pred = cls_pred.sigmoid()
      neg_cost = (
          -(1 - cls_pred + self.eps).log()
          * (1 - self.alpha)
          * cls_pred.pow(self.gamma)
      )
      pos_cost = (
          -(cls_pred + self.eps).log()
          * self.alpha
          * (1 - cls_pred).pow(self.gamma)
      )
  
      cls_cost = torch.einsum(
          "nc,mc->nm", pos_cost, gt_labels
      ) + torch.einsum("nc,mc->nm", neg_cost, (1 - gt_labels))
      return cls_cost / n * self.weight
  
imports: from abc import abstractmethod
  from typing import Optional, Union
  import torch
  import torch.nn.functional
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import bbox_overlaps, bbox_xyxy_to_cxcywh
label_desc: Use image node_id 3 for calling the FocalLossCost obj's underlying member method code with example usage: obj._mask_focal_loss_cost(cls_pred, gt_labels) and returns: unknown