code: def _generate_epoch(
      self, text_only
  ) -> Generator[InputSample, None, None]:
      fold_id = -1
      for p, page in enumerate(self.book.pages):
          if self.mode in INPUT_PROCESSOR:
              img = self._load_image(page.imgFile)
              if self.params.binary:
                  img = img > 0.9
          else:
              img = None
  
          for l, line in enumerate(page.getLines()):
              for f, fo in enumerate(line.formats):
                  fold_id += 1
                  sample_id = "{}_{}_{}_{}".format(
                      split_all_ext(page.xmlFile or page.imgFile)[0],
                      p,
                      l,
                      f,
                  )
                  text = None
                  if self.mode in TARGETS_PROCESSOR:
                      text = fo.text
  
                  if text_only:
                      yield InputSample(
                          None,
                          text,
                          SampleMeta(id=sample_id, fold_id=fold_id),
                      )
  
                  else:
                      cut_img = None
                      if self.mode in INPUT_PROCESSOR:
                          ly, lx = img.shape
  
                          # Cut the Image
                          cut_img = img[
                              line.rect.top : -ly + line.rect.bottom,
                              line.rect.left : -lx + line.rect.right,
                          ]
  
                          # add padding as required from normal files
                          cut_img = np.pad(
                              cut_img,
                              ((3, 3), (0, 0)),
                              mode="constant",
                              constant_values=cut_img.max(),
                          )
  
                      yield InputSample(
                          cut_img,
                          text,
                          SampleMeta(id=sample_id, fold_id=fold_id),
                      )
  
imports: import logging
  from copy import deepcopy
  from dataclasses import dataclass, field
  from typing import List, Generator
  import numpy
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.pipeline.definitions import PipelineMode, TARGETS_PROCESSOR, INPUT_PROCESSOR
  from tqdm import tqdm
  from calamari_ocr.ocr.dataset.datareader.abbyy.xml import XMLReader, XMLWriter
  from calamari_ocr.ocr.dataset.datareader.base import CalamariDataGenerator, CalamariDataGeneratorParams, InputSample, SampleMeta
  from calamari_ocr.utils import split_all_ext, glob_all
label_desc: Use image node_id 5 for calling the AbbyyGenerator obj's underlying member method code with example usage: obj._generate_epoch(text_only) without return types