code: def save_hdf5(filename, obj, compression=4):
      """Saves an object to the file in HDF5 format.
  
      This is a short-cut function to save only one object into an HDF5 file. If
      you want to save multiple objects to one HDF5 file, use
      :class:`HDF5Serializer` directly by passing appropriate :class:`h5py.Group`
      objects.
  
      Args:
          filename (str): Target file name.
          obj: Object to be serialized. It must support serialization protocol.
              If it is a dictionary object, the serialization will be skipped.
          compression (int): Gzip compression level.
  
      .. note::
          Currently :func:`save_hdf5` only supports writing to an actual file on
          file system due to a limitation of HD5F library.
          See `h5py/h5py#687 <https://github.com/h5py/h5py/issues/687>`_ for
          details.
  
      .. seealso::
          :func:`chainer.serializers.load_hdf5`
  
      """
      _check_available()
      with h5py.File(filename, "w") as f:
          if isinstance(obj, dict):
              for key, value in obj.items():
                  key = "/" + key.lstrip("/")
                  arr = numpy.asarray(value)
                  compression = None if arr.size <= 1 else compression
                  try:
                      f.create_dataset(
                          key, data=arr, compression=compression
                      )
                  except TypeError:
                      sys.stderr.write(
                          'A key named "{}" is unable to save in HDF5 format.\n'
                      )
                      # In Chainer, LogReport extension and PlotReport extension
                      # are # unable to save in HDF5 format. These extensions
                      # have a data type `numpy.dtype('O')` which is not
                      # supported by h5py.
                      six.reraise(*sys.exec_info())
          else:
              s = HDF5Serializer(f, compression=compression)
              s.save(obj)
  
imports: import sys
  import numpy
  import six
  from chainer.backends import _chainerx
  from chainer.backends import _cpu
  from chainer.backends import cuda
  from chainer.backends import intel64
  from chainer import serializer
  import chainerx
label_desc: Use image node_id 2 for calling a global function with example usage: save_hdf5(filename, obj, compression) without return types