def check_solution(task, solution_string, ops_namespace=None):
  """Checks whether solution_string passes all examples in the task."""
  for example_index in range(task.num_examples):
    namespace = ops_namespace.copy() if ops_namespace else {}
    for input_name, input_values in task.inputs_dict.items():
      namespace[input_name] = input_values[example_index]
    try:
      result = eval(solution_string, {'__builtins__': {}}, namespace)  # pylint: disable=eval-used
      if result != task.outputs[example_index]:
        return False
    except:  # pylint: disable=bare-except
      return False
  return True