def execute_mathqa_program(problem, program):
  """Executes the DSL code for a given problem.

  Args:
    problem: problem formulation (not needed, but we want the same API as
      in the DSL case).
    program: Python code.

  Returns:
    the result of executing of the Python code.
  """
  del problem  # problem only needed in the DSL version.
  # Programs are lists of strings. We need to concatenate them in order to exec.
  program = '\n'.join(program)
  var_dict = {}
  try:
    # The logic of this is the following: if exec with timeout is working
    # without exceptions, then we can call exec again and gather the variables.
    exec(program, globals(), var_dict)  # pylint: disable=exec-used
    if 'answer' in var_dict and is_number(var_dict['answer']):
      return float(var_dict['answer'])
    else:
      return None
  except:  # pylint: disable=bare-except
    return None
Executes the DSL code for a given problem.

  Args:
    problem: problem formulation (not needed, but we want the same API as
      in the DSL case).
    program: Python code.

  Returns:
    the result of executing of the Python code.
  
trax/data/tf_inputs.py