code: def save_hdf5(fpath, data, verbose=None, compression='lzf'):
      r
      import h5py
      verbose = _rectify_verb_write(verbose)
      if verbose:
          print('[util_io] * save_hdf5(%r, data)' % (util_path.tail(fpath),))
      if verbose > 1:
          if isinstance(data, dict):
              print('[util_io] ... shapes=%r' % ([val.shape for val in data.values()],))
          else:
              print('[util_io] ... shape=%r' % (data.shape,))
      chunks = True
      fname = basename(fpath)
      h5kw = {}
      if isinstance(data, dict):
          array_data = {key: val for key, val in data.items()
                        if isinstance(val, (list, np.ndarray))}
          attr_data = {key: val for key, val in data.items() if key not in array_data}
          with h5py.File(fpath, mode='w', **h5kw) as file_:
              grp = file_.create_group(fname)
              for key, val in six.iteritems(array_data):
                  val = np.asarray(val)
                  dset = grp.create_dataset(
                      key, val.shape,  val.dtype, chunks=chunks,
                      compression=compression)
                  dset[...] = val
              for key, val in six.iteritems(attr_data):
                  grp.attrs[key] = val
      else:
          assert isinstance(data, np.ndarray)
          shape = data.shape
          dtype = data.dtype
          with h5py.File(fpath, mode='w', **h5kw) as file_:
              dset = file_.create_dataset(
                  fname, shape,  dtype, chunks=chunks, compression=compression)
              dset[...] = data