code: def _validate_dataset(
      ds,
      input_size,
      batch_size=2,
      class_indices=False,
      is_polygons=False,
  ):
      # Fetch one sample
      img, target = ds[0]
      assert isinstance(img, tf.Tensor)
      assert img.shape == (*input_size, 3)
      assert img.dtype == tf.float32
      assert isinstance(target, dict)
      assert (
          isinstance(target["boxes"], np.ndarray)
          and target["boxes"].dtype == np.float32
      )
      if is_polygons:
          assert target["boxes"].ndim == 3 and target["boxes"].shape[
              1:
          ] == (4, 2)
      else:
          assert target["boxes"].ndim == 2 and target["boxes"].shape[
              1:
          ] == (4,)
      assert np.all(
          np.logical_and(target["boxes"] <= 1, target["boxes"] >= 0)
      )
      if class_indices:
          assert (
              isinstance(target["labels"], np.ndarray)
              and target["labels"].dtype == np.int64
          )
      else:
          assert isinstance(target["labels"], list) and all(
              isinstance(s, str) for s in target["labels"]
          )
      assert len(target["labels"]) == len(target["boxes"])
  
      # Check batching
      loader = DataLoader(ds, batch_size=batch_size)
  
      images, targets = next(iter(loader))
      assert isinstance(images, tf.Tensor) and images.shape == (
          batch_size,
          *input_size,
          3,
      )
      assert isinstance(targets, list) and all(
          isinstance(elt, dict) for elt in targets
      )
  
imports: import os
  from shutil import move
  import numpy
  import pytest
  import tensorflow
  from doctr import datasets
  from doctr.datasets import DataLoader
  from doctr.file_utils import CLASS_NAME
  from doctr.transforms import Resize
label_desc: Use image node_id 1 for calling a global function with example usage: _validate_dataset(ds, input_size, batch_size, class_indices, is_polygons) without return types