class_docstr: Cross entropy loss function for image classification tasks
  
  Args:
      opts: command-line arguments
class_docstr_tok: ["Cross","entropy","loss","function","for","image","classification","tasks","Args",":","opts",":","command-line","arguments"]
docstr: Computes cross-entropy loss between prediction and target tensors.
  
  Args:
      prediction: Predicted tensor of shape [N, C]
      target: Target label tensor of shape [N] containing values between [0, C),
  
      Here, :math:`C` is the number of classes and :math:`N` is the batch size
  
  Returns:
      A scalar loss value
docstr_tok: ["Computes","cross-entropy","loss","between","prediction","and","target","tensors",".","Args",":","prediction",":","Predicted","tensor","of","shape","[","N",",","C","]","target",":","Target","label","tensor","of","shape","[","N","]","containing","values","between","[","0",",","C",")",",","Here",",",":","math",":","`","C","`","is","the","number","of","classes","and",":","math",":","`","N","`","is","the","batch","size","Returns",":","A","scalar","loss","value"]
code: def _compute_loss(
      self, prediction: Tensor, target: Tensor, *args, **kwargs
  ) -> Tensor:
      """Computes cross-entropy loss between prediction and target tensors.
  
      Args:
          prediction: Predicted tensor of shape [N, C]
          target: Target label tensor of shape [N] containing values between [0, C),
  
          Here, :math:`C` is the number of classes and :math:`N` is the batch size
  
      Returns:
          A scalar loss value
      """
      weight = None
      if self.use_class_wts and self.training:
          n_classes = prediction.shape[1]
          weight = compute_class_weights(
              target=target, n_classes=n_classes
          )
  
      # for validation, we compute standard CE loss
      label_smoothing_val = (
          self.label_smoothing if self.training else 0.0
      )
      return F.cross_entropy(
          input=prediction,
          target=target,
          weight=weight,
          ignore_index=self.ignore_idx,
          label_smoothing=label_smoothing_val,
      )
  
file_path: ml-cvnets/loss_fn/classification/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
  from loss_fn.utils.class_weighting import compute_class_weights
label_desc: Use image node_id 3 for calling the CrossEntropy obj's underlying member method code with example usage: obj._compute_loss(prediction, target) and returns: F