import tensorflow as tf

    items = sorted(items, key=lambda x: x[0])
    existing = {}
    for name, params in items:
        outdir = params.save_episode_dir
        tf.gfile.MakeDirs(outdir)
        if outdir not in existing:
            existing[outdir] = len(tf.gfile.Glob(os.path.join(outdir, '*.npz')))
        if params.num_episodes <= existing[outdir]:
