class_docstr: Implementation of the self training kowledge distillation framework from the paper
  "Revisit Knowledge Distillation: a Teacher-free Framework" https://arxiv.org/abs/1909.11723
  
  
  :param student_model (torch.nn.Module): Student model
  :param train_loader (torch.utils.data.DataLoader): Dataloader for training
  :param val_loader (torch.utils.data.DataLoader): Dataloader for validation/testing
  :param optimizer_student (torch.optim.*): Optimizer used for training student
  :param loss_fn (torch.nn.Module):  Calculates loss during distillation
  :param temp (float): Temperature parameter for distillation
  :param distil_weight (float): Weight paramter for distillation loss
  :param device (str): Device used for training; 'cpu' for cpu and 'cuda' for gpu
  :param rkd_angle (float): Angle ratio for RKD loss if used
  :param rkd_dist (float): Distance ratio for RKD loss if used
  :param log (bool): True if logging required
  :param logdir (str): Directory for storing logs
class_docstr_tok: ["Implementation","of","the","self","training","kowledge","distillation","framework","from","the","paper","''","Revisit","Knowledge","Distillation",":","a","Teacher-free","Framework","''","https",":","\/\/arxiv.org\/abs\/1909.11723",":","param","student_model","(","torch.nn.Module",")",":","Student","model",":","param","train_loader","(","torch.utils.data.DataLoader",")",":","Dataloader","for","training",":","param","val_loader","(","torch.utils.data.DataLoader",")",":","Dataloader","for","validation\/testing",":","param","optimizer_student","(","torch.optim",".","*",")",":","Optimizer","used","for","training","student",":","param","loss_fn","(","torch.nn.Module",")",":","Calculates","loss","during","distillation",":","param","temp","(","float",")",":","Temperature","parameter","for","distillation",":","param","distil_weight","(","float",")",":","Weight","paramter","for","distillation","loss",":","param","device","(","str",")",":","Device","used","for","training",";","'cpu","'","for","cpu","and","'cuda","'","for","gpu",":","param","rkd_angle","(","float",")",":","Angle","ratio","for","RKD","loss","if","used",":","param","rkd_dist","(","float",")",":","Distance","ratio","for","RKD","loss","if","used",":","param","log","(","bool",")",":","True","if","logging","required",":","param","logdir","(","str",")",":","Directory","for","storing","logs"]
docstr: Function used for calculating the KD loss during distillation
  
  :param y_pred_student (torch.FloatTensor): Prediction made by the student model
  :param y_pred_teacher (torch.FloatTensor): Prediction made by the teacher model
  :param y_true (torch.FloatTensor): Original label
docstr_tok: ["Function","used","for","calculating","the","KD","loss","during","distillation",":","param","y_pred_student","(","torch.FloatTensor",")",":","Prediction","made","by","the","student","model",":","param","y_pred_teacher","(","torch.FloatTensor",")",":","Prediction","made","by","the","teacher","model",":","param","y_true","(","torch.FloatTensor",")",":","Original","label"]
code: def calculate_kd_loss(self, y_pred_student, y_pred_teacher, y_true):
      """
      Function used for calculating the KD loss during distillation
  
      :param y_pred_student (torch.FloatTensor): Prediction made by the student model
      :param y_pred_teacher (torch.FloatTensor): Prediction made by the teacher model
      :param y_true (torch.FloatTensor): Original label
      """
  
      loss = (1 - self.distil_weight) * F.cross_entropy(
          y_pred_student, y_true
      )
      loss += (self.distil_weight) * self.loss_fn(
          F.log_softmax(y_pred_student, dim=1),
          F.softmax(y_pred_teacher / self.temp, dim=1),
      )
      return loss
  
file_path: KD_Lib/KD_Lib/KD/vision/teacher_free/self_training.py
imports: from copy import deepcopy
  import matplotlib.pyplot
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 3 for calling the SelfTraining obj's underlying member method code with example usage: obj.calculate_kd_loss(y_pred_student, y_pred_teacher, y_true) and returns: loss