code: def _dicts_to_group(h5file, path, d, raise_meta_fail):
      for key, item in d.items():
          if isinstance(item, np.ndarray):
              if item.dtype == np.dtype("O"):
                  # see if h5py is ok with it
                  try:
                      h5file[path + key] = item
                      # h5file[path + key].attrs['dtype'] = item.dtype.str
                  except TypeError:
                      msg = (
                          "numpy dtype 'O' for item:\n{}\n"
                          "not supported by HDF5\n{}"
                          "".format(item, traceback.format_exc())
                      )
  
                      if raise_meta_fail:
                          raise TypeError(msg)
                      else:
                          h5file[path + key] = str(item)
                          warn(
                              "{}, storing whatever str(obj) returns"
                              "".format(msg)
                          )
  
              # numpy array of unicode strings
              elif item.dtype.str.startswith("<U"):
                  h5file[path + key] = item.astype(
                      h5py.special_dtype(vlen=str)
                  )
  
                  # otherwise h5py doesn't restore the right dtype for str types
                  h5file[path + key].attrs["dtype"] = item.dtype.str
  
              # other types
              else:
                  h5file[path + key] = item
                  # h5file[path + key].attrs['dtype'] = item.dtype.str
  
          # single pieces of data
          elif isinstance(
              item,
              (
                  str,
                  int,
                  np.int8,
                  np.int16,
                  np.int32,
                  np.int64,
                  float,
                  np.float16,
                  np.float32,
                  np.float64,
              ),
          ):
              h5file[path + key] = item
  
          elif isinstance(item, dict):
              _dicts_to_group(
                  h5file,
                  "{}{}/".format(path, key),
                  item,
                  raise_meta_fail,
              )
  
          # last resort, try to convert this object
          # to a dict and save its attributes
          elif hasattr(item, "__dict__"):
              _dicts_to_group(
                  h5file,
                  "{}{}/".format(path, key),
                  item.__dict__,
                  raise_meta_fail,
              )
  
          else:
              msg = "{} for item: {} not supported by HDF5" "".format(
                  type(item), item
              )
  
              if raise_meta_fail:
                  raise TypeError(msg)
  
              else:
                  h5file[path + key] = str(item)
                  warn(
                      "{}, storing whatever str(obj) returns"
                      "".format(msg)
                  )
  
file_path: tslearn/tslearn/hdftools/hdftools.py
imports: import h5py
  import os
  import numpy
  import traceback
  from warnings import warn
label_desc: Use image node_id 2 for calling a global function with example usage: _dicts_to_group(h5file, path, d, raise_meta_fail) without return types