def METHOD_NAME(cls_list, data_dict, num_sample_cls):
    """Traverse the categories and extract `num_sample_cls` image
    indexes of the corresponding categories one by one."""
    id_indices = []
    for _ in range(len(cls_list)):
        cls_idx = next(cls_list)
        for _ in range(num_sample_cls):
            id = next(data_dict[cls_idx])
            id_indices.append(id)
    return id_indices