code: def __init__(self, mode: PipelineMode, params: Hdf5):
      super(Hdf5Generator, self).__init__(mode, params)
      self.prediction = None
      if (
          mode == PipelineMode.PREDICTION
          or mode == PipelineMode.EVALUATION
      ):
          self.prediction = {}
  
      for filename in self.params.files:
          f = h5py.File(filename, "r")
          codec = list(map(chr, f["codec"]))
          if (
              mode == PipelineMode.PREDICTION
              or mode == PipelineMode.EVALUATION
          ):
              self.prediction[filename] = {
                  "transcripts": [],
                  "codec": codec,
              }
  
          basename = split_all_ext(filename)[0]
  
          # create empty samples for id and correct dataset size
          for i, text in enumerate(f["transcripts"]):
              self.add_sample(
                  {
                      "image": None,
                      "text": "",
                      "id": f"{basename}/{i}",
                      "filename": filename,
                  }
              )
  
imports: from copy import deepcopy
  from dataclasses import dataclass, field
  from random import shuffle
  from typing import Generator, List
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.pipeline.definitions import PipelineMode
  import numpy
  import h5py
  from calamari_ocr.ocr.dataset.datareader.base import CalamariDataGenerator, InputSample, SampleMeta, CalamariDataGeneratorParams
  from calamari_ocr.utils import split_all_ext, glob_all
label_desc: Use image node_id 1 to create a new Hdf5Generator object from inherited base classes: CalamariDataGenerator with example: obj = Hdf5Generator(mode, params)