class_docstr: FocalLossCost.
  
  Args:
      weight (int | float, optional): loss_weight
      alpha (int | float, optional): focal_loss alpha
      gamma (int | float, optional): focal_loss gamma
      eps (float, optional): default 1e-12
      binary_input (bool, optional): Whether the input is binary,
         default False.
class_docstr_tok: ["FocalLossCost",".","Args",":","weight","(","int","|","float",",","optional",")",":","loss_weight","alpha","(","int","|","float",",","optional",")",":","focal_loss","alpha","gamma","(","int","|","float",",","optional",")",":","focal_loss","gamma","eps","(","float",",","optional",")",":","default","1e-12","binary_input","(","bool",",","optional",")",":","Whether","the","input","is","binary",",","default","False","."]
docstr: Args:
      cls_pred (Tensor): Predicted classfication logits
          in shape (num_query, d1, ..., dn), dtype=paddle.float32.
      gt_labels (Tensor): Ground truth in shape (num_gt, d1, ..., dn),
          dtype=paddle.long. Labels should be binary.
  
  Returns:
      Tensor: Focal cost matrix with weight in shape                (num_query, num_gt).
docstr_tok: ["Args",":","cls_pred","(","Tensor",")",":","Predicted","classfication","logits","in","shape","(","num_query",",","d1",",","...",",","dn",")",",","dtype=paddle.float32",".","gt_labels","(","Tensor",")",":","Ground","truth","in","shape","(","num_gt",",","d1",",","...",",","dn",")",",","dtype=paddle.long",".","Labels","should","be","binary",".","Returns",":","Tensor",":","Focal","cost","matrix","with","weight","in","shape","(","num_query",",","num_gt",")","."]
code: def _mask_focal_loss_cost(self, cls_pred, gt_labels):
      """
          Args:
              cls_pred (Tensor): Predicted classfication logits
                  in shape (num_query, d1, ..., dn), dtype=paddle.float32.
              gt_labels (Tensor): Ground truth in shape (num_gt, d1, ..., dn),
                  dtype=paddle.long. Labels should be binary.
  
          Returns:
              Tensor: Focal cost matrix with weight in shape\
                  (num_query, num_gt).
          """
      cls_pred = cls_pred.flatten(1)
      gt_labels = gt_labels.flatten(1).float()
      n = cls_pred.shape[1]
      cls_pred = F.sigmoid(cls_pred)
      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 = paddle.einsum(
          "nc,mc->nm", pos_cost, gt_labels
      ) + paddle.einsum("nc,mc->nm", neg_cost, (1 - gt_labels))
      return cls_cost / n * self.weight
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
  import paddle.nn.functional
  from ppdet.core.workspace import register
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