code: def _read_sample(self, index: int) -> Tuple[Any, str]:
      # Samples are already cached
      if len(self._data) > 0:
          pil_img, target = self._data[index]
      else:
          target = self._generate_string(*self.wordlen_range)
          pil_img = synthesize_text_img(
              target, font_family=random.choice(self.font_family)
          )
      img = tensor_from_pil(pil_img)
  
      return img, target
  
file_path: doctr/doctr/datasets/generator/base.py
imports: import random
  from typing import Any, Callable, List, Optional, Tuple, Union
  from PIL import Image, ImageDraw
  from doctr.io.image import tensor_from_pil
  from doctr.utils.fonts import get_font
  from ..datasets import AbstractDataset
label_desc: Use image node_id 4 for calling the _WordGenerator obj's underlying member method code with example usage: obj._read_sample(index) and returns: img,  target