cherry pick batch_option.py from automatic_branch