def METHOD_NAME(unused_argv):
  game = factory.create_game_with_setting(FLAGS.game_name, FLAGS.env_setting)
  uniform_policy = policy.UniformRandomPolicy(game)
  mfg_dist = distribution.DistributionPolicy(game, uniform_policy)
  envs = [
      rl_environment.Environment(
          game, mfg_distribution=mfg_dist, mfg_population=p)
      for p in range(game.num_players())
  ]
  info_state_size = envs[0].observation_spec()["info_state"][0]
  num_actions = envs[0].action_spec()["num_actions"]
  hidden_layers_sizes = [int(l) for l in FLAGS.hidden_layers_sizes]
  kwargs = {
      "replay_buffer_capacity": FLAGS.replay_buffer_capacity,
      "min_buffer_size_to_learn": FLAGS.min_buffer_size_to_learn,
      "batch_size": FLAGS.batch_size,
      "learn_every": FLAGS.learn_every,
      "learning_rate": FLAGS.rl_learning_rate,
      "optimizer_str": FLAGS.optimizer_str,
      "loss_str": FLAGS.loss_str,
      "update_target_network_every": FLAGS.update_target_network_every,
      "discount_factor": FLAGS.discount_factor,
      "epsilon_decay_duration": FLAGS.epsilon_decay_duration,
      "epsilon_start": FLAGS.epsilon_start,
      "epsilon_end": FLAGS.epsilon_end,
  }
  # pylint: disable=g-complex-comprehension
  agents = [
      dqn.DQN(idx, info_state_size, num_actions, hidden_layers_sizes, **kwargs)
      for idx in range(game.num_players())
  ]
  joint_avg_policy = rl_agent_policy.JointRLAgentPolicy(
      game, {idx: agent for idx, agent in enumerate(agents)},
      envs[0].use_observation)
  if FLAGS.use_checkpoints:
    for agent in agents:
      if agent.has_checkpoint(FLAGS.checkpoint_dir):
        agent.restore(FLAGS.checkpoint_dir)
  # Metrics writer will also log the metrics to stderr.
  just_logging = FLAGS.logdir is None or jax.host_id() > 0
  writer = metrics.create_default_writer(
      logdir=FLAGS.logdir, just_logging=just_logging)
  # Save the parameters.
  writer.write_hparams(kwargs)
  for ep in range(1, FLAGS.num_train_episodes + 1):
    if ep % FLAGS.eval_every == 0:
      writer.write_scalars(ep, {
          f"agent{i}/loss": float(agent.loss) for i, agent in enumerate(agents)
      })
      initial_states = game.new_initial_states()
      # Exact best response to uniform.
      nash_conv_obj = nash_conv.NashConv(game, uniform_policy)
      writer.write_scalars(
          ep, {
              f"exact_br/{state}": value
              for state, value in zip(initial_states, nash_conv_obj.br_values())
          })
      # DQN best response to uniform.
      pi_value = policy_value.PolicyValue(game, mfg_dist, joint_avg_policy)
      writer.write_scalars(ep, {
          f"dqn_br/{state}": pi_value.eval_state(state)
          for state in initial_states
      })
      if FLAGS.use_checkpoints:
        for agent in agents:
          agent.save(FLAGS.checkpoint_dir)
    for p in range(game.num_players()):
      time_step = envs[p].reset()
      while not time_step.last():
        agent_output = agents[p].step(time_step)
        action_list = [agent_output.action]
        time_step = envs[p].step(action_list)
      # Episode is over, step all agents with final info state.
      agents[p].step(time_step)
  # Make sure all values were written.
  writer.flush()