class_docstr: Soft KL Loss for classification tasks. Given an input sample, soft-labels (or probabilities)
  are generated from a teacher and KL loss is computed between soft-labels and student model's output.
  
  Args:
      opts: command-line arguments
class_docstr_tok: ["Soft","KL","Loss","for","classification","tasks",".","Given","an","input","sample",",","soft-labels","(","or","probabilities",")","are","generated","from","a","teacher","and","KL","loss","is","computed","between","soft-labels","and","student","model","'s","output",".","Args",":","opts",":","command-line","arguments"]
docstr: Computes distillation loss.
  
  Args:
      input_sample: Input image tensor
      prediction: Student model's output.
  
  Shapes:
      input_sample: Shape is [Batch size, 3, height, width]
      prediction: Shape is [Batch size, number of classes]
  
  Returns:
      A scalar loss value.
docstr_tok: ["Computes","distillation","loss",".","Args",":","input_sample",":","Input","image","tensor","prediction",":","Student","model","'s","output",".","Shapes",":","input_sample",":","Shape","is","[","Batch","size",",","3",",","height",",","width","]","prediction",":","Shape","is","[","Batch","size",",","number","of","classes","]","Returns",":","A","scalar","loss","value","."]
code: def _forward_distill(
      self, input_sample: Tensor, prediction: Tensor, *args, **kwargs
  ) -> Tensor:
      """Computes distillation loss.
  
      Args:
          input_sample: Input image tensor
          prediction: Student model's output.
  
      Shapes:
          input_sample: Shape is [Batch size, 3, height, width]
          prediction: Shape is [Batch size, number of classes]
  
      Returns:
          A scalar loss value.
      """
      with torch.no_grad():
          teacher_logits = self._logits_from_teacher(input_sample)
          teacher_lprobs = F.log_softmax(
              teacher_logits / self.temperature, dim=1
          ).detach()
  
      student_lprobs = F.log_softmax(
          prediction / self.temperature, dim=-1
      )
      kl_loss = F.kl_div(
          student_lprobs,
          teacher_lprobs,
          reduction="batchmean",
          log_target=True,
      )
      return kl_loss * (self.temperature**2)
  
file_path: ml-cvnets/loss_fn/distillation/soft_kl_distillation.py
imports: import argparse
  import torch
  from torch import Tensor
  from torch.nn import functional
  from loss_fn import LOSS_REGISTRY
  from loss_fn.distillation.base_distillation import BaseDistillationCriteria
  from utils import logger
label_desc: Use image node_id 3 for calling the SoftKLLoss obj's underlying member method code with example usage: obj._forward_distill(input_sample, prediction) and returns: unknown