nodes: 0, module; 1, function_definition; 2, function_name:group_pairs; 3, parameters; 4, block; 5, identifier:blocks; 6, identifier:layout_blocks_list; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Sort a list of layout blocks into pairs
  
      Arguments:
      List:blocks        -- List of block objects
      List:layout_blocks -- List of layout block indexes
  
      Returns:
      List -- Layout block pair indexes grouped in a list
      """; 13, assignment; 14, identifier:block_id; 15, identifier:layout_blocks_list; 16, block; 17, call; 18, call; 19, identifier:image_dict; 20, dictionary; 21, expression_statement; 22, if_statement; 23, identifier:log; 24, argument_list; 25, identifier:list; 26, argument_list; 27, assignment; 28, comparison_operator:image_seq not in image_dict; 29, block; 30, else_clause; 31, identifier:group_pairs; 32, binary_operator:'Layout blocks found at PEBs: %s' % list(image_dict.values()); 33, call; 34, identifier:image_seq; 35, attribute; 36, identifier:image_seq; 37, identifier:image_dict; 38, expression_statement; 39, block; 40, string; 41, call; 42, attribute; 43, argument_list; 44, attribute; 45, identifier:image_seq; 46, assignment; 47, expression_statement; 48, string_content:Layout blocks found at PEBs: %s; 49, identifier:list; 50, argument_list; 51, identifier:image_dict; 52, identifier:values; 53, subscript; 54, identifier:ec_hdr; 55, subscript; 56, list; 57, call; 58, call; 59, identifier:blocks; 60, identifier:block_id; 61, identifier:image_dict; 62, identifier:image_seq; 63, identifier:block_id; 64, attribute; 65, argument_list; 66, attribute; 67, argument_list; 68, subscript; 69, identifier:append; 70, identifier:block_id; 71, identifier:image_dict; 72, identifier:values; 73, identifier:image_dict; 74, identifier:image_seq
code: def group_pairs(blocks, layout_blocks_list):
      """Sort a list of layout blocks into pairs
  
      Arguments:
      List:blocks        -- List of block objects
      List:layout_blocks -- List of layout block indexes
  
      Returns:
      List -- Layout block pair indexes grouped in a list
      """
  
      image_dict={}
      for block_id in layout_blocks_list:
          image_seq=blocks[block_id].ec_hdr.image_seq
          if image_seq not in image_dict:
              image_dict[image_seq]=[block_id]
          else:
              image_dict[image_seq].append(block_id)
  
      log(group_pairs, 'Layout blocks found at PEBs: %s' % list(image_dict.values()))
  
      return list(image_dict.values())