Get Policy and Value for each network, for each position

    Usage:
        python3 sharp_positions.py evaluate --sgf_dir data/s --model_dir models/

def evaluate():
    """Get Policy and Value for each network, for each position

    Usage:
        python3 sharp_positions.py evaluate --sgf_dir data/s --model_dir models/
    """

    def short_str(v):
        if isinstance(v, float):
            return "{.3f}".format(v)
        return str(v)

    # Load positons
    sgf_names, all_positions = get_final_positions()

    # Run and save some data about each position
    # Save to csv because that's easy
    model_paths = oneoff_utils.get_model_paths(FLAGS.model_dir)
    num_models = len(model_paths)
    print("Evaluating {} models: {} to {}".format(
        num_models, model_paths[0], model_paths[-1]))
    print()

    with open(FLAGS.results, "w") as results:
        results.write(",".join(sgf_names) + "\n")

        player = None
        for idx in tqdm(range(FLAGS.min_idx, num_models, 1), desc="model"):
            model = model_paths[idx]

            if player and idx % 50 == 0:
                player.network.sess.close()
                tf.reset_default_graph()
                player = None

            if player:
                oneoff_utils.restore_params(model, player)
            else:
                player = oneoff_utils.load_player(model)

            row = [model]
            for positions in grouper(FLAGS.batch_size, all_positions):
                probs, values = player.network.run_many(positions)
                # NOTE(sethtroisi): For now we store the top n moves to shrink
                # the size of the recorded data.

                top_n = FLAGS.top_n
                top_policy_move = np.fliplr(np.argsort(probs))[:,:top_n]
                top_policy_value = np.fliplr(np.sort(probs))[:,:top_n]

                # One position at a time
                for v, m, p in zip(values, top_policy_move, top_policy_value):
                    row.append(v)
                    row.extend(itertools.chain.from_iterable(zip(m, p)))

                if len(positions) > 10:
                    average_seen = top_policy_value.sum() / len(positions)
                    if average_seen < 0.3:
                        print("\t", average_seen, top_policy_value.sum(axis=-1))

            results.write(",".join(map(short_str, row)) + "\n")