def run(self) -> None:
    """Main entry point for this class."""
    self.validate_flags_or_throw()

    tf.gfile.MakeDirs(self.output_dir)

    tf.disable_v2_behavior()

    num_train_steps = None
    num_warmup_steps = None
    if self.do_train:
      with tf.gfile.Open(self.record_count_file, "r") as f:
        num_train_features = int(f.read().strip())
      num_train_steps = int(num_train_features / self.train_batch_size *
                            self.num_train_epochs)
      logging.info("record_count_file: %s", self.record_count_file)
      logging.info("num_records (features): %d", num_train_features)
      logging.info("num_train_epochs: %d", self.num_train_epochs)
      logging.info("train_batch_size: %d", self.train_batch_size)
      logging.info("num_train_steps: %d", num_train_steps)

      num_warmup_steps = int(num_train_steps * self.warmup_proportion)

    model_fn = self.get_model_fn(num_train_steps, num_warmup_steps)
    estimator = self.get_estimator(model_fn)

    if self.do_train:
      logging.info("Running training on precomputed features")
      logging.info("  Num split examples = %d", num_train_features)
      logging.info("  Batch size = %d", self.train_batch_size)
      logging.info("  Num steps = %d", num_train_steps)
      train_filenames = tf.gfile.Glob(self.train_records_file)
      train_input_fn = tf_io.input_fn_builder(
          input_file=train_filenames,
          seq_length=self.max_seq_length,
          is_training=True,
          drop_remainder=True)
      estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)

    if self.do_predict:
      self.predict(estimator)
Main entry point for this class.
language/canine/tydiqa/run_tydi_lib.py