docstr: Simple, reliable and slow implementation of batch by size
docstr_tok: ["Simple",",","reliable","and","slow","implementation","of","batch","by","size"]
code: def batch_by_size_baseline(
      cls,
      indices,
      num_tokens_vec,
      max_tokens,
      max_sentences,
      bsz_mult,
  ):
      """Simple, reliable and slow implementation of batch by size"""
      batches = []
      start = 0
      while start < len(indices):
          for end in range(start + 1, len(indices) + 1):
              max_val = max(
                  num_tokens_vec[pos] for pos in range(start, end)
              )
              sent_count = end - start
              num_tokens = max_val * sent_count
              overflow = (
                  num_tokens > max_tokens > 0
                  or sent_count > max_sentences > 0
              )
              terminate = overflow or end == len(indices)
              if overflow:
                  sent_count -= 1
              if terminate:
                  if sent_count > bsz_mult:
                      sent_count = sent_count - sent_count % bsz_mult
                  batches.append(indices[start : start + sent_count])
                  start = start + sent_count
                  break
      return batches
  
file_path: fairseq/tests/test_data_utils.py
imports: import unittest
  import numpy
  from fairseq.data.data_utils_fast import batch_by_size_fn, batch_by_size_vec
label_desc: Use image node_id 1 for calling the TestBatchBySize obj's underlying member method code with example usage: obj.batch_by_size_baseline(cls, indices, num_tokens_vec, max_tokens, max_sentences, bsz_mult) and returns: batches