code: def learn(self, boards, target_pis, target_vs, optimizer):
      self.model.train()  # train mode
  
      # compute model output
      out_log_pi, out_v = self.model(boards)
  
      pi_loss = (
          -torch.sum(target_pis * out_log_pi) / target_pis.size()[0]
      )
  
      v_loss = (
          torch.sum((target_vs - out_v.view(-1)) ** 2)
          / target_vs.size()[0]
      )
  
      total_loss = pi_loss + v_loss
  
      # compute gradient and do SGD step
      optimizer.zero_grad()
      total_loss.backward()
      optimizer.step()
  
      return total_loss, pi_loss, v_loss
  
file_path: PARL/benchmark/torch/AlphaZero/alphazero_agent.py
imports: import os
  import numpy
  import parl
  import torch
  import torch.optim
  from tqdm import tqdm
  from utils import *
  from connect4_model import Connect4Model
label_desc: Use image node_id 2 for calling the AlphaZero obj's underlying member method code with example usage: obj.learn(boards, target_pis, target_vs, optimizer) and returns: total_loss,  pi_loss,  v_loss