nodes: 0, module; 1, function_definition; 2, function_name:sort_by_formula_id; 3, parameters; 4, block; 5, identifier:raw_datasets; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""
      Sort a list of formulas by `id`, where `id` represents the accepted
      formula id.
  
      Parameters
      ----------
      raw_datasets : list of dictionaries
          A list of raw datasets.
  
      Examples
      --------
      The parameter `raw_datasets` has to be of the format
  
      >>> rd = [{'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=2953),
      ...        'formula_in_latex': 'A',
      ...        'id': 2953},
      ...       {'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=4037),
      ...        'formula_in_latex': 'A',
      ...        'id': 4037},
      ...       {'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=4056),
      ...        'formula_in_latex': 'A',
      ...        'id': 4056}]
      >>> sort_by_formula_id(rd)
      """; 11, assignment; 12, identifier:el; 13, identifier:raw_datasets; 14, block; 15, identifier:by_formula_id; 16, identifier:by_formula_id; 17, call; 18, expression_statement; 19, identifier:defaultdict; 20, argument_list; 21, call; 22, identifier:list; 23, attribute; 24, argument_list; 25, subscript; 26, identifier:append; 27, subscript; 28, identifier:by_formula_id; 29, attribute; 30, identifier:el; 31, string; 32, subscript; 33, identifier:formula_id; 34, string_content:handwriting; 35, identifier:el; 36, string; 37, string_content:handwriting
code: def sort_by_formula_id(raw_datasets):
      """
      Sort a list of formulas by `id`, where `id` represents the accepted
      formula id.
  
      Parameters
      ----------
      raw_datasets : list of dictionaries
          A list of raw datasets.
  
      Examples
      --------
      The parameter `raw_datasets` has to be of the format
  
      >>> rd = [{'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=2953),
      ...        'formula_in_latex': 'A',
      ...        'id': 2953},
      ...       {'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=4037),
      ...        'formula_in_latex': 'A',
      ...        'id': 4037},
      ...       {'is_in_testset': 0,
      ...        'formula_id': 31,
      ...        'handwriting': HandwrittenData(raw_data_id=4056),
      ...        'formula_in_latex': 'A',
      ...        'id': 4056}]
      >>> sort_by_formula_id(rd)
      """
      by_formula_id = defaultdict(list)
      for el in raw_datasets:
          by_formula_id[el['handwriting'].formula_id].append(el['handwriting'])
      return by_formula_id