code: def dataset_generator(
      filepath, dataset, chunk_size=1, start_idx=None, end_idx=None
  ):
      """Generate example dicts."""
      encoder = dna_encoder.DNAEncoder(chunk_size=chunk_size)
      with h5py.File(filepath, "r") as h5_file:
          # Get input keys from h5_file
          src_keys = [s % dataset for s in ["%s_in", "%s_na", "%s_out"]]
          src_values = [h5_file[k] for k in src_keys]
          inp_data, mask_data, out_data = src_values
          assert len(set([v.len() for v in src_values])) == 1
  
          if start_idx is None:
              start_idx = 0
          if end_idx is None:
              end_idx = inp_data.len()
  
          for i in range(start_idx, end_idx):
              if i % 100 == 0:
                  print("Generating example %d for %s" % (i, dataset))
              inputs, mask, outputs = (
                  inp_data[i],
                  mask_data[i],
                  out_data[i],
              )
              ex_dict = to_example_dict(encoder, inputs, mask, outputs)
              # Original data has one output for every 128 input bases. Ensure that the
              # ratio has been maintained given the chunk size and removing EOS.
              assert (len(ex_dict["inputs"]) - 1) == (
                  (128 // chunk_size) * ex_dict["targets_shape"][0]
              )
              yield ex_dict
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import multiprocessing
  import os
  import h5py
  import numpy
  from six.moves import range
  from tensor2tensor.data_generators import dna_encoder
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_encoder
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import metrics
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: dataset_generator(filepath, dataset, chunk_size, start_idx, end_idx) without return types