code: def consolidate_metadata(store, metadata_key='.zmetadata'):
      
      store = normalize_store_arg(store)
  
      def is_zarr_key(key):
          return (key.endswith('.zarray') or key.endswith('.zgroup') or
                  key.endswith('.zattrs'))
  
      out = {
          'zarr_consolidated_format': 1,
          'metadata': {
              key: json_loads(store[key])
              for key in store if is_zarr_key(key)
          }
      }
      store[metadata_key] = json_dumps(out)
      return open_consolidated(store, metadata_key=metadata_key)
docs: Consolidate all metadata for groups and arrays within the given store
      into a single resource and put it under the given key.
  
      This produces a single object in the backend store, containing all the
      metadata read from all the zarr-related keys that can be found. After
      metadata have been consolidated, use :func:`open_consolidated` to open
      the root group in optimised, read-only mode, using the consolidated
      metadata to reduce the number of read operations on the backend store.
  
      Note, that if the metadata in the store is changed after this
      consolidation, then the metadata read by :func:`open_consolidated`
      would be incorrect unless this function is called again.
  
      .. note:: This is an experimental feature.
  
      Parameters
      ----------
      store : MutableMapping or string
          Store or path to directory in file system or name of zip file.
      metadata_key : str
          Key to put the consolidated metadata under.
  
      Returns
      -------
      g : :class:`zarr.hierarchy.Group`
          Group instance, opened with the new consolidated metadata.
  
      See Also
      --------
      open_consolidated