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"]
code: def __init__(
      self,
      student_model,
      train_loader,
      val_loader,
      optimizer_student,
      loss_fn=nn.KLDivLoss(),
      temp=10.0,
      distil_weight=0.5,
      device="cpu",
      log=False,
      logdir="./Experiments",
  ):
      self.student_model = student_model
      self.train_loader = train_loader
      self.val_loader = val_loader
      self.optimizer_student = optimizer_student
      self.loss_fn = loss_fn
      self.temp = temp
      self.distil_weight = distil_weight
      self.log = log
      self.logdir = logdir
  
      if self.log:
          self.writer = SummaryWriter(logdir)
  
      try:
          torch.Tensor(0).to(device)
          self.device = device
      except:
          print(
              "Either an invalid device or CUDA is not available. Defaulting to CPU."
          )
          self.device = "cpu"
  
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 1 to create a new SelfTraining object  with example: obj = SelfTraining(student_model, train_loader, val_loader, optimizer_student, loss_fn, temp, distil_weight, device, log, logdir)