code: def dict_to_archive(data, archive_format="gztar"):
      """Transform a {path: content} dict to an archive.
  
      Parameters
      ----------
      data : dict
          Keys are strings or `pathlib.Path` objects and specify paths inside the
          archive. (If strings, must use the system path separator.)
          Values determine the contents of these files and can be:
            - an object with a `to_filename` method (e.g. a Nifti1Image): it is
              serialized to .nii.gz
            - a `pathlib.Path`: the contents are copied inside the archive (can
              point to a file or a directory). (can also be anything that has
              `is_file` and `is_directory` attributes, e.g. a `pathlib2.Path`)
            - a `str` or `bytes`: the contents of the file
            - anything else is pickled.
  
      archive_format : str, optional (default="gztar")
          The archive format. See `shutil` documentation for available formats.
  
      Returns
      -------
      bytes : the contents of the resulting archive file, to be used for example
          as the contents of a mock response object (see Sender).
  
      Examples
      --------
      if `data` is `{"README.txt": "hello", Path("Data") / "labels.csv": "a,b"}`,
      the resulting archive has this structure:
          .
          ├── Data
          │   └── labels.csv
          └── README.txt
  
      where labels.csv and README.txt contain the corresponding values in `data`
  
      """
      with tempfile.TemporaryDirectory() as root_tmp_dir:
          root_tmp_dir = Path(root_tmp_dir)
          tmp_dir = root_tmp_dir / "tmp"
          tmp_dir.mkdir()
          for path, content in data.items():
              _add_to_archive(tmp_dir / path, content)
          archive_path = shutil.make_archive(
              str(root_tmp_dir / "archive"),
              archive_format,
              str(tmp_dir),
          )
          with open(archive_path, "rb") as f:
              return f.read()
  
imports: import fnmatch
  import json
  import os
  import pickle
  import re
  import shutil
  import tempfile
  from collections import OrderedDict
  from pathlib import Path
  from unittest.mock import MagicMock
  import pytest
  from requests.exceptions import HTTPError
  from nilearn._utils.testing import serialize_niimg
label_desc: Use image node_id 7 for calling a global function with example usage: dict_to_archive(data, archive_format) and returns: f