code: def split_in_batches(nmr_elements, max_batch_size):
      
      offset = 0
      elements_left = nmr_elements
      while elements_left > 0:
          next_batch = (offset, offset + min(elements_left, max_batch_size))
          yield next_batch
  
          batch_size = min(elements_left, max_batch_size)
          elements_left -= batch_size
          offset += batch_size
docs: Split the total number of elements into batches of the specified maximum size.
  
      Examples::
          split_in_batches(30, 8) -> [(0, 8), (8, 15), (16, 23), (24, 29)]
  
          for batch_start, batch_end in split_in_batches(2000, 100):
              array[batch_start:batch_end]
  
      Yields:
          tuple: the start and end point of the next batch