code: def h5_to_dict(h5: h5py.Group) -> Dict[str, Any]:
      """Converts an h5 group to a nested dict."""
      out_dict = {}
  
      def visitor(path, obj):
          if not isinstance(obj, h5py.Dataset):
              return
          elems = path.split("/")
          cur_dict = out_dict
          for e in elems[:-1]:
              new_dict = cur_dict.get(e)
              if new_dict is None:
                  new_dict = {}
                  cur_dict[e] = new_dict
              cur_dict = new_dict
  
          cur_dict[elems[-1]] = np.array(obj)
  
      h5.visititems(visitor)
  
      return out_dict
  
imports: import contextlib
  import io
  from typing import Any, Dict, Iterator
  from absl import flags
  from etils import epath
  import gin
  import h5py
  import jax
  import numpy
  import tree
  import yaml
label_desc: Use image node_id 3 for calling a global function with example usage: h5_to_dict(h5) and returns: out_dict