class_docstr: Implementation of paper "Born Again Neural Networks"
  https://arxiv.org/abs/1805.04770
  
  :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
  :param optimizer (torch.optim.*): Optimizer for training
  :param num_gen (int): Number of generations to train.
  :param loss_fn (torch.nn.Module): Loss Function used for first model in gen.
                                    later, KLDivLoss is used.
  :param temp (float): Temperature parameter for distillation
  :param distil_weight (float): Weight paramter for distillation loss
  :param device (str): Device 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","paper","``","Born","Again","Neural","Networks","''","https",":","\/\/arxiv.org\/abs\/1805.04770",":","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",":","param","optimizer","(","torch.optim",".","*",")",":","Optimizer","for","training",":","param","num_gen","(","int",")",":","Number","of","generations","to","train",".",":","param","loss_fn","(","torch.nn.Module",")",":","Loss","Function","used","for","first","model","in","gen.","later",",","KLDivLoss","is","used",".",":","param","temp","(","float",")",":","Temperature","parameter","for","distillation",":","param","distil_weight","(","float",")",":","Weight","paramter","for","distillation","loss",":","param","device","(","str",")",":","Device","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 that will be training the student
  
  :param epochs (int): Number of epochs you want to train the student per generation
  :param plot_losses (bool): True if you want to plot the losses for every generation
  :param save_model (bool): True if you want to save the student model (Set true if you want to use models for later evaluation)
  :param save_model_pth (str): Path where you want to save the student model
docstr_tok: ["Function","that","will","be","training","the","student",":","param","epochs","(","int",")",":","Number","of","epochs","you","want","to","train","the","student","per","generation",":","param","plot_losses","(","bool",")",":","True","if","you","want","to","plot","the","losses","for","every","generation",":","param","save_model","(","bool",")",":","True","if","you","want","to","save","the","student","model","(","Set","true","if","you","want","to","use","models","for","later","evaluation",")",":","param","save_model_pth","(","str",")",":","Path","where","you","want","to","save","the","student","model"]
code: def train_student(
      self,
      epochs=10,
      plot_losses=False,
      save_model=True,
      save_model_pth="./models/student-{}.pth",
  ):
      """
      Function that will be training the student
  
      :param epochs (int): Number of epochs you want to train the student per generation
      :param plot_losses (bool): True if you want to plot the losses for every generation
      :param save_model (bool): True if you want to save the student model (Set true if you want to use models for later evaluation)
      :param save_model_pth (str): Path where you want to save the student model
      """
      try:
          fmt = save_model_pth.format(1)
      except:
          print(
              "Invalid save_model_pth, allow {\} for generation number"
          )
          return
      for k in range(self.num_gen):
          print("Born Again : Gen {}/{}".format(k + 1, self.num_gen))
  
          self._train_student(
              epochs,
              plot_losses,
              save_model,
              save_model_pth.format(k + 1),
          )
  
          # Use best model in k-1 gen as last model
          self.teacher_model.load_state_dict(
              self.best_student_model_weights
          )
          # Reset model for next generation
          self.student_model.load_state_dict(self.init_weights)
          # Reset optimizer for next generation
          self.optimizer_student.load_state_dict(self.init_optim)
          self.gen += 1
  
file_path: KD_Lib/KD_Lib/KD/vision/BANN/BANN.py
imports: import glob
  import os
  from copy import deepcopy
  import torch
  import torch.nn
  import torch.nn.functional
  from KD_Lib.KD.common import BaseClass
label_desc: Use image node_id 2 for calling the BANN obj's underlying member method code with example usage: obj.train_student(epochs, plot_losses, save_model, save_model_pth) without return types