code: def test_charactergenerator():
      input_size = (32, 32)
      vocab = "abcdef"
  
      ds = datasets.CharacterGenerator(
          vocab=vocab,
          num_samples=10,
          cache_samples=True,
          img_transforms=Resize(input_size),
      )
  
      assert len(ds) == 10
      image, label = ds[0]
      assert isinstance(image, torch.Tensor)
      assert image.shape[-2:] == input_size
      assert image.dtype == torch.float32
      assert isinstance(label, int) and label < len(vocab)
  
      loader = DataLoader(ds, batch_size=2, collate_fn=ds.collate_fn)
      images, targets = next(iter(loader))
      assert isinstance(images, torch.Tensor) and images.shape == (
          2,
          3,
          *input_size,
      )
      assert isinstance(targets, torch.Tensor) and targets.shape == (2,)
      assert targets.dtype == torch.int64
  
imports: import os
  from shutil import move
  import numpy
  import pytest
  import torch
  from torch.utils.data import DataLoader, RandomSampler
  from doctr import datasets
  from doctr.file_utils import CLASS_NAME
  from doctr.transforms import Resize
label_desc: Use image node_id 7 for calling a global function with example usage: test_charactergenerator() without return types