class_docstr: Basic implementation of a general Knowledge Distillation framework
  
  :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 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 that will be training the teacher
  
  :param epochs (int): Number of epochs you want to train the teacher
  :param plot_losses (bool): True if you want to plot the losses
  :param save_model (bool): True if you want to save the teacher model
  :param save_model_pth (str): Path where you want to store the teacher model
docstr_tok: ["Function","that","will","be","training","the","teacher",":","param","epochs","(","int",")",":","Number","of","epochs","you","want","to","train","the","teacher",":","param","plot_losses","(","bool",")",":","True","if","you","want","to","plot","the","losses",":","param","save_model","(","bool",")",":","True","if","you","want","to","save","the","teacher","model",":","param","save_model_pth","(","str",")",":","Path","where","you","want","to","store","the","teacher","model"]
code: def train_teacher(
      self,
      epochs=20,
      plot_losses=True,
      save_model=True,
      save_model_pth="./models/teacher.pt",
  ):
      """
      Function that will be training the teacher
  
      :param epochs (int): Number of epochs you want to train the teacher
      :param plot_losses (bool): True if you want to plot the losses
      :param save_model (bool): True if you want to save the teacher model
      :param save_model_pth (str): Path where you want to store the teacher model
      """
      self.teacher_model.train()
      loss_arr = []
      length_of_dataset = len(self.train_loader.dataset)
      best_acc = 0.0
      self.best_teacher_model_weights = deepcopy(
          self.teacher_model.state_dict()
      )
  
      save_dir = os.path.dirname(save_model_pth)
      if not os.path.exists(save_dir):
          os.makedirs(save_dir)
  
      print("Training Teacher... ")
  
      for ep in range(epochs):
          epoch_loss = 0.0
          correct = 0
          for data, label in self.train_loader:
              data = data.to(self.device)
              label = label.to(self.device)
              out = self.teacher_model(data)
  
              if isinstance(out, tuple):
                  out = out[0]
  
              pred = out.argmax(dim=1, keepdim=True)
              correct += pred.eq(label.view_as(pred)).sum().item()
  
              loss = self.ce_fn(out, label)
  
              self.optimizer_teacher.zero_grad()
              loss.backward()
              self.optimizer_teacher.step()
  
              epoch_loss += loss.item()
  
          epoch_acc = correct / length_of_dataset
  
          epoch_val_acc = self.evaluate(teacher=True)
  
          if epoch_val_acc > best_acc:
              best_acc = epoch_val_acc
              self.best_teacher_model_weights = deepcopy(
                  self.teacher_model.state_dict()
              )
  
          if self.log:
              self.writer.add_scalar(
                  "Training loss/Teacher", epoch_loss, epochs
              )
              self.writer.add_scalar(
                  "Training accuracy/Teacher", epoch_acc, epochs
              )
              self.writer.add_scalar(
                  "Validation accuracy/Teacher", epoch_val_acc, epochs
              )
  
          loss_arr.append(epoch_loss)
          print(
              "Epoch: {}, Loss: {}, Accuracy: {}".format(
                  ep + 1, epoch_loss, epoch_acc
              )
          )
  
          self.post_epoch_call(ep)
  
      self.teacher_model.load_state_dict(
          self.best_teacher_model_weights
      )
      if save_model:
          torch.save(self.teacher_model.state_dict(), save_model_pth)
      if plot_losses:
          plt.plot(loss_arr)
  
file_path: KD_Lib/KD_Lib/KD/common/base_class.py
imports: import os
  from copy import deepcopy
  import matplotlib.pyplot
  import torch
  import torch.nn
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 2 for calling the BaseClass obj's underlying member method code with example usage: obj.train_teacher(epochs, plot_losses, save_model, save_model_pth) without return types