code: def load_dataset(path, label_dict, outdir=None):
      """Load and save HDF5 that contains a dataset and stats for LM
  
      Args:
          path (str): The path of an input text dataset file
          label_dict (dict[str, int]):
              dictionary that maps token label string to its ID number
          outdir (str): The path of an output dir
  
      Returns:
          tuple[list[np.ndarray], int, int]: Tuple of
              token IDs in np.int32 converted by `read_tokens`
              the number of tokens by `count_tokens`,
              and the number of OOVs by `count_tokens`
      """
      if outdir is not None:
          os.makedirs(outdir, exist_ok=True)
          filename = outdir + "/" + os.path.basename(path) + ".h5"
          if os.path.exists(filename):
              logging.info(f"loading binary dataset: {filename}")
              f = h5py.File(filename, "r")
              return f["data"][:], f["n_tokens"][()], f["n_oovs"][()]
      else:
          logging.info(
              "skip dump/load HDF5 because the output dir is not specified"
          )
      logging.info(f"reading text dataset: {path}")
      ret = read_tokens(path, label_dict)
      n_tokens, n_oovs = count_tokens(ret, label_dict["<unk>"])
      if outdir is not None:
          logging.info(f"saving binary dataset: {filename}")
          with h5py.File(filename, "w") as f:
              # http://docs.h5py.org/en/stable/special.html#arbitrary-vlen-data
              data = f.create_dataset(
                  "data",
                  (len(ret),),
                  dtype=h5py.special_dtype(vlen=np.int32),
              )
              data[:] = ret
              f["n_tokens"] = n_tokens
              f["n_oovs"] = n_oovs
      return ret, n_tokens, n_oovs
  
imports: import logging
  import os
  import random
  import chainer
  import h5py
  import numpy
  from chainer.training import extension
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: load_dataset(path, label_dict, outdir) and returns: ret,  n_tokens,  n_oovs, f,  f,  f