code: def _batched(
      iterator: Iterator[T] | Iterable[T], n: int
  ) -> Iterator[List[T]]:
      """Batches the result of an iterator into lists of length n.
  
      This function is built-in the standard library from 3.12 (source:
      https://docs.python.org/3/library/itertools.html#itertools.batched). However,
      TFDS supports older versions of Python.
  
      Args:
        iterator: The iterator to batch.
        n: The maximal length of each batch.
  
      Yields:
        The next list of n elements.
      """
      i = 0
      while True:
          batch = list(itertools.islice(iterator, i, i + n))
          if not batch:
              return
          yield batch
          i += n
  
imports: from __future__ import annotations
  import abc
  from collections.abc import Iterator
  import enum
  import itertools
  import os
  from typing import Any, ClassVar, Dict, Iterable, List, Optional, Type, TypeVar, Union
  import uuid
  from etils import epath
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import array_record_module
  from tensorflow_datasets.core.utils.lazy_imports_utils import pyarrow
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _batched(iterator, n) without return types