def process_single_mathqa_example(example):
  """Execute a single example and verify coherence of a MathQA problem.

  Args:
    example: a dictionary with the following fields: Problem - a natural
      language formulation of the problem Rationale - a natural language
      solution of the problem options - five possible answers ( a) b) c) d) and
      e) ) correct - the letter representing the correct answer
      annotated_formula - formula representing the full solution linear_formula
      - a string of operations separated by the | character, e.g.
      multiply(n2,const_100)|multiply(n0,n1)|divide(#0,#1)|
      multiply(#2,const_100)|divide(#3,#1)| category - a natural language
      description of the category to which a given problem belongs.

  Returns:
    answer_num: numerical answer contained in the example
    python_result: numerical answers computed in Python, including intermediate
      results. The answer_num should be close python_result[-1]
    list_op: list of arithmetic operations
    list_num: list of identified numbers in the text
  """
  question = example['Problem']
  list_num = compute_nums(question)
  list_op = compute_ops(example['linear_formula'])
  answers = example['options']
  correct_answer = example['correct']
  index = answers.find('{} )'.format(correct_answer))
  answer_string = re.findall(
      r'[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?', answers[index:])
  # The if statement deals with empty lists - they are needed to treat
  # a correct non-numerical answer e) None of the above. Here we do not want
  # non-numerical answers, hence we return None.
  if answer_string:
    answer_num = float(
        re.findall(r'[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?',
                   answers[index:])[0].replace(',', ''))
  else:
    return None
  # The if statements below deals with answers written as fractions e.g.
  # a ) 1 / 2 , b ) 1 / 3 , c ) 1 / 5 , d ) 10 / 30 , e ) 2 / 5 ?
  index_end_of_answer = index + len(str(answer_num)) + 3
  if index_end_of_answer < len(answers) and answers[index_end_of_answer] == '/':
    answer_denom = float(
        re.findall(r'[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?',
                   answers[index_end_of_answer:])[0].replace(',', ''))
    answer_num /= answer_denom
  python_result = compute_result(list_op, list_num)
  python_program = compute_program(list_op)
  return answer_num, python_result, python_program, list_op, list_num
Execute a single example and verify coherence of a MathQA problem.

  Args:
    example: a dictionary with the following fields: Problem - a natural
      language formulation of the problem Rationale - a natural language
      solution of the problem options - five possible answers ( a) b) c) d) and
      e) ) correct - the letter representing the correct answer
      annotated_formula - formula representing the full solution linear_formula
      - a string of operations separated by the | character, e.g.
      multiply(n2,const_100)|multiply(n0,n1)|divide(#0,#1)|
      multiply(#2,const_100)|divide(#3,#1)| category - a natural language
      description of the category to which a given problem belongs.

  Returns:
    answer_num: numerical answer contained in the example
    python_result: numerical answers computed in Python, including intermediate
      results. The answer_num should be close python_result[-1]
    list_op: list of arithmetic operations
    list_num: list of identified numbers in the text
  
trax/data/tf_inputs.py