class_docstr: Binary cross-entropy loss for classification tasks
  
  Args:
      opts: command-line arguments
docstr: The binary cross-entropy loss with logits for binary classification.
  The probability for class one is the Sigmoid on the logit.
  For multi-class problems with multiple valid labels, the loss penalizes by
  the given target probability of the same shape as predictions.
  
  Args:
      prediction: Logits of class 1
      target: Ground-truth class index or probability.
  
  Shapes:
      prediction: [Batch size, ...]
      target: A tensor of similar shape to prediction if the target
          probability for each output is known. Or a tensor of ground-truth labels
          missing the last dimension of size `num_classes`.
  
  Returns:
      If reduction is none, then tensor of the same shape as prediction is returned.
      Otherwise, a scalar loss value is returned.
docstr_tok: ["The","binary","cross-entropy","loss","with","logits","for","binary","classification",".","The","probability","for","class","one","is","the","Sigmoid","on","the","logit",".","For","multi-class","problems","with","multiple","valid","labels",",","the","loss","penalizes","by","the","given","target","probability","of","the","same","shape","as","predictions",".","Args",":","prediction",":","Logits","of","class","1","target",":","Ground-truth","class","index","or","probability",".","Shapes",":","prediction",":","[","Batch","size",",","...","]","target",":","A","tensor","of","similar","shape","to","prediction","if","the","target","probability","for","each","output","is","known",".","Or","a","tensor","of","ground-truth","labels","missing","the","last","dimension","of","size","`","num_classes","`",".","Returns",":","If","reduction","is","none",",","then","tensor","of","the","same","shape","as","prediction","is","returned",".","Otherwise",",","a","scalar","loss","value","is","returned","."]
code: def _compute_loss(
      self, prediction: Tensor, target: Tensor, *args, **kwargs
  ) -> Tensor:
      """The binary cross-entropy loss with logits for binary classification.
      The probability for class one is the Sigmoid on the logit.
      For multi-class problems with multiple valid labels, the loss penalizes by
      the given target probability of the same shape as predictions.
  
      Args:
          prediction: Logits of class 1
          target: Ground-truth class index or probability.
  
      Shapes:
          prediction: [Batch size, ...]
          target: A tensor of similar shape to prediction if the target
              probability for each output is known. Or a tensor of ground-truth labels
              missing the last dimension of size `num_classes`.
  
      Returns:
          If reduction is none, then tensor of the same shape as prediction is returned.
          Otherwise, a scalar loss value is returned.
      """
      if target.dim() == (prediction.dim() - 1):
          # Ground truth labels are hard labels. Convert to one-hot labels.
          target = F.one_hot(target, num_classes=prediction.shape[-1])
  
      div_by = 1.0
      if self.reduction == "batch_mean":
          div_by = target.shape[0]
      reduction = (
          self.reduction if self.reduction != "batch_mean" else "sum"
      )
  
      bce_loss = F.binary_cross_entropy_with_logits(
          input=prediction,
          target=target.to(prediction.dtype),
          reduction=reduction,
      )
  
      return bce_loss / div_by
  
file_path: ml-cvnets/loss_fn/classification/binary_cross_entropy.py
imports: import argparse
  from torch import Tensor
  from torch.nn import functional
  from loss_fn import LOSS_REGISTRY
  from loss_fn.classification.base_classification_criteria import BaseClassificationCriteria
label_desc: Use image node_id 3 for calling the BinaryCrossEntropy obj's underlying member method code with example usage: obj._compute_loss(prediction, target) and returns: unknown