docstr: Collecting training data by self-play.
  
  Args:
      current_weights (numpy.array): latest weights of neural network
      game_num (int): game number of self-play
  
  Returns:
      train_examples (list): examples of the form (canonicalBoard, currPlayer, pi,v)
docstr_tok: ["Collecting","training","data","by","self-play",".","Args",":","current_weights","(","numpy.array",")",":","latest","weights","of","neural","network","game_num","(","int",")",":","game","number","of","self-play","Returns",":","train_examples","(","list",")",":","examples","of","the","form","(","canonicalBoard",",","currPlayer",",","pi",",","v",")"]
code: def self_play(self, current_weights, game_num):
      """Collecting training data by self-play.
  
      Args:
          current_weights (numpy.array): latest weights of neural network
          game_num (int): game number of self-play
  
      Returns:
          train_examples (list): examples of the form (canonicalBoard, currPlayer, pi,v)
      """
  
      # update weights of current neural network with latest weights
      self.current_agent.set_weights(current_weights)
  
      train_examples = []
      for _ in range(game_num):
          # reset node state of MCTS
          self.current_mcts = MCTS(
              self.game,
              self.current_agent,
              self.args,
              dirichlet_noise=True,
          )
          train_examples.extend(self._executeEpisode())
      return train_examples
  
file_path: PARL/benchmark/torch/AlphaZero/actor.py
imports: import numpy
  import parl
  import os
  from alphazero_agent import create_agent
  from MCTS import MCTS
  from Arena import Arena
  from utils import win_loss_draw
label_desc: Use image node_id 2 for calling the Actor obj's underlying member method code with example usage: obj.self_play(current_weights, game_num) and returns: train_examples