def execute_mathqa_dsl_program(problem, dsl_code):
  """Executes the DSL code for a given problem.

  Args:
    problem: problem formulation (needed to get parameters).
    dsl_code: DSL code.

  Returns:
    the result of executing of the DSL code.
  """
  n0_loc = problem.find('n0')
  list_num = compute_nums(problem[n0_loc:])
  # The list contains _all_ numbers in the string, hence in particular
  # for n0 = 2.0 n1 = 3.0 we are getting list_num = [0.0, 2.0, 1.0, 3.0],
  # so that below we are filtering the odd occurrences.
  assert len(list_num) % 2 == 0
  list_num = [list_num[2 * i + 1] for i in range(int(len(list_num) / 2))]

  # dsl_code is a list of strings; since all DSL programs are single liners,
  # we need to guess the correct line. For now we use the same location as in
  # in the ground truth examples, that is the first line.
  list_op = compute_ops(dsl_code[0])

  try:
    results = compute_result(list_op, list_num)[-1]
  except:  # pylint: disable=bare-except
    results = None
  return results
Executes the DSL code for a given problem.

  Args:
    problem: problem formulation (needed to get parameters).
    dsl_code: DSL code.

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