docstr: Args:
      examples: list of examples, each example is of form (board, pi, v)
docstr_tok: ["Args",":","examples",":","list","of","examples",",","each","example","is","of","form","(","board",",","pi",",","v",")"]
code: def learn(self, examples):
      """
      Args:
          examples: list of examples, each example is of form (board, pi, v)
      """
      optimizer = optim.Adam(self.alg.model.parameters(), lr=args.lr)
  
      for epoch in range(args.epochs):
          print("EPOCH ::: " + str(epoch + 1))
  
          batch_count = int(len(examples) / args.batch_size)
  
          pbar = tqdm(range(batch_count), desc="Training Net")
          for _ in pbar:
              sample_ids = np.random.randint(
                  len(examples), size=args.batch_size
              )
              boards, pis, vs = list(
                  zip(*[examples[i] for i in sample_ids])
              )
              boards = torch.FloatTensor(
                  np.array(boards).astype(np.float64)
              )
              target_pis = torch.FloatTensor(np.array(pis))
              target_vs = torch.FloatTensor(
                  np.array(vs).astype(np.float64)
              )
  
              if self.cuda:
                  boards, target_pis, target_vs = (
                      boards.contiguous().cuda(),
                      target_pis.contiguous().cuda(),
                      target_vs.contiguous().cuda(),
                  )
  
              total_loss, pi_loss, v_loss = self.alg.learn(
                  boards, target_pis, target_vs, optimizer
              )
  
              # record loss with tqdm
              pbar.set_postfix(
                  Loss_pi=pi_loss.item(), Loss_v=v_loss.item()
              )
  
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 AlphaZeroAgent obj's underlying member method code with example usage: obj.learn(examples) without return types