code: def array_to_hdf5(a, parent, name, **kwargs):
      
  
      import h5py
  
      h5f = None
  
      if isinstance(parent, str):
          h5f = h5py.File(parent, mode='a')
          parent = h5f
  
      try:
  
          kwargs.setdefault('chunks', True)  # auto-chunking
          kwargs.setdefault('dtype', a.dtype)
          kwargs.setdefault('compression', 'gzip')
          h5d = parent.require_dataset(name, shape=a.shape, **kwargs)
          h5d[...] = a
          return h5d
  
      finally:
          if h5f is not None:
              h5f.close()
docs: Write a Numpy array to an HDF5 dataset.
  
      Parameters
      ----------
      a : ndarray
          Data to write.
      parent : string or h5py group
          Parent HDF5 file or group. If a string, will be treated as HDF5 file
          name.
      name : string
          Name or path of dataset to write data into.
      kwargs : keyword arguments
          Passed through to h5py require_dataset() function.
  
      Returns
      -------
      h5d : h5py dataset