def validate_flags_or_throw(bert_config):
  """Validate the input FLAGS or throw an exception."""
  if (not FLAGS.do_train and not FLAGS.do_predict and
      not FLAGS.do_embed_docs and not FLAGS.do_embed_qrys and
      not FLAGS.do_test):
    raise ValueError("At least one of `do_train` or `do_predict` or "
                     "`do_embed_docs` or `do_embed_qrys` must be True.")

  if FLAGS.do_train:
    if not FLAGS.train_file:
      raise ValueError(
          "If `do_train` is True, then `train_file` must be specified.")
  if FLAGS.do_predict:
    if not FLAGS.predict_file:
      raise ValueError(
          "If `do_predict` is True, then `predict_file` must be specified.")
  if FLAGS.do_embed_docs:
    if not FLAGS.doc_embed_file:
      raise ValueError(
          "If `do_embed_docs` is True, then `doc_embed_file` must be "
          "specified.")
  if FLAGS.do_embed_qrys:
    if not FLAGS.qry_embed_file:
      raise ValueError(
          "If `do_embed_qrys` is True, then `qry_embed_file` must be "
          "specified.")

  if FLAGS.max_seq_length > bert_config.max_position_embeddings:
    raise ValueError(
        "Cannot use sequence length %d because the BERT model "
        "was only trained up to sequence length %d" %
        (FLAGS.max_seq_length, bert_config.max_position_embeddings))

  if FLAGS.max_seq_length <= FLAGS.max_query_length + 3:
    raise ValueError(
        "The max_seq_length (%d) must be greater than max_query_length "
        "(%d) + 3" % (FLAGS.max_seq_length, FLAGS.max_query_length))
Validate the input FLAGS or throw an exception.
language/labs/drkit/run_dualencoder_lsf.py