code: def subdivide_batch(batch, accumulate_gradient):
      batch = list(batch)
      batch.sort(key=lambda eg: len(eg.predicted))
      sub_len = len(batch) // accumulate_gradient
      start = 0
      for i in range(accumulate_gradient):
          subbatch = batch[start : start + sub_len]
          if subbatch:
              yield subbatch
          start += len(subbatch)
      subbatch = batch[start:]
      if subbatch:
          yield subbatch
  
file_path: spacy/spacy/training/loop.py
imports: import random
  import shutil
  import sys
  from pathlib import Path
  from timeit import default_timer
  from typing import IO, TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
  from thinc.api import Config, Optimizer, constant, fix_random_seed, set_gpu_allocator
  from wasabi import Printer
  from ..errors import Errors
  from ..schemas import ConfigSchemaTraining
  from ..util import logger, registry, resolve_dot_names
  from .example import Example
label_desc: Use image node_id 3 for calling a global function with example usage: subdivide_batch(batch, accumulate_gradient) without return types