class_docstr: Implementation of equal epoch interval route constrained optimization
  from the paper "Knowledge Distillation via Route Constrained Optimization"
  https://arxiv.org/abs/1904.09149
  
  :param teacher_model (torch.nn.Module): Teacher model
  :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_teacher (torch.optim.*): Optimizer used for training teacher
  :param optimizer_student (torch.optim.*): Optimizer used for training student
  :param loss_fn (torch.nn.Module): Loss Function used for distillation
  :param epoch_interval (int): Number of epochs after which teacher anchor points are created
  :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 log (bool): True if logging required
  :param logdir (str): Directory for storing logs
class_docstr_tok: ["Implementation","of","equal","epoch","interval","route","constrained","optimization","from","the","paper","``","Knowledge","Distillation","via","Route","Constrained","Optimization","''","https",":","\/\/arxiv.org\/abs\/1904.09149",":","param","teacher_model","(","torch.nn.Module",")",":","Teacher","model",":","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_teacher","(","torch.optim",".","*",")",":","Optimizer","used","for","training","teacher",":","param","optimizer_student","(","torch.optim",".","*",")",":","Optimizer","used","for","training","student",":","param","loss_fn","(","torch.nn.Module",")",":","Loss","Function","used","for","distillation",":","param","epoch_interval","(","int",")",":","Number","of","epochs","after","which","teacher","anchor","points","are","created",":","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","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 (Tensor): Predicted outputs from the student network
  :param y_pred_teacher (Tensor): Predicted outputs from the teacher network
  :param y_true (Tensor): True labels
docstr_tok: ["Function","used","for","calculating","the","KD","loss","during","distillation",":","param","y_pred_student","(","Tensor",")",":","Predicted","outputs","from","the","student","network",":","param","y_pred_teacher","(","Tensor",")",":","Predicted","outputs","from","the","teacher","network",":","param","y_true","(","Tensor",")",":","True","labels"]
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 (Tensor): Predicted outputs from the student network
      :param y_pred_teacher (Tensor): Predicted outputs from the teacher network
      :param y_true (Tensor): True labels
      """
  
      loss = (1 - self.distil_weight) * F.cross_entropy(
          F.softmax(y_pred_student, dim=1), y_true
      )
      loss += (
          self.distil_weight * self.temp * self.temp
      ) * self.loss_fn(
          F.log_softmax(y_pred_student / self.temp, dim=1),
          F.log_softmax(y_pred_teacher / self.temp, dim=1),
      )
  
      return loss
  
file_path: KD_Lib/KD_Lib/KD/vision/RCO/rco.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
  from KD_Lib.KD.common import BaseClass
label_desc: Use image node_id 4 for calling the RCO obj's underlying member method code with example usage: obj.calculate_kd_loss(y_pred_student, y_pred_teacher, y_true) and returns: loss