def inference(input_path, predictions_path, checkpoint, dataset_name):
  """Runs inference locally.

  Args:
    input_path: The TFRecord file with the input examples.
    predictions_path: The filepath to save example predictions (as a .jsonl).
    checkpoint: Filepath to the model save checkpoint.
    dataset_name: Name of the dataset.
  """
  fn = RunInferenceDoFn(checkpoint)

  # Load and process the TFRecords. First, inference is ran on these records
  # without looking at the gold query.
  examples = list()
  record_iterator = tf.python_io.tf_record_iterator(path=input_path)
  for record in record_iterator:
    example = tf.train.SequenceExample()
    example.ParseFromString(record)
    examples.append(example)

  # The predictions are written to the path that only contains predictions
  with tf.gfile.Open(predictions_path, 'w') as ofile:
    for example in examples:
      ofile.write(json.dumps(fn.non_parallel_process(example)) + '\n')
Runs inference locally.

  Args:
    input_path: The TFRecord file with the input examples.
    predictions_path: The filepath to save example predictions (as a .jsonl).
    checkpoint: Filepath to the model save checkpoint.
    dataset_name: Name of the dataset.
  
language/xsp/model/run_inference.py