code: def test_dict_to_archive(tmp_path):
      subdir = tmp_path / "tmp"
      subdir.mkdir()
      (subdir / "labels.csv").touch()
      (subdir / "img.nii.gz").touch()
      archive_spec = {
          "empty_data": subdir,
          "empty_data_path.txt": str(subdir),
          Path("data", "labels.csv"): "a,b,c",
          Path("data", "img.nii.gz"): generate_fake_fmri()[0],
          Path("a", "b", "c"): (100).to_bytes(
              length=1, byteorder="big", signed=False
          ),
      }
      targz = _testing.dict_to_archive(archive_spec)
      extract_dir = tmp_path / "extract"
      extract_dir.mkdir()
      archive_path = tmp_path / "archive"
      with archive_path.open("wb") as f:
          f.write(targz)
      with tarfile.open(str(archive_path)) as tarf:
          tarf.extractall(str(extract_dir))
      img = image.load_img(str(extract_dir / "data" / "img.nii.gz"))
  
      assert img.shape == (10, 11, 12, 17)
      with (extract_dir / "a" / "b" / "c").open("rb") as f:
          assert (
              int.from_bytes(f.read(), byteorder="big", signed=False)
              == 100
          )
      with open(str(extract_dir / "empty_data" / "labels.csv")) as f:
          assert f.read() == ""
  
      zip_archive = _testing.dict_to_archive(
          {"readme.txt": "hello", "archive": targz}, "zip"
      )
      with archive_path.open("wb") as f:
          f.write(zip_archive)
  
      with zipfile.ZipFile(str(archive_path)) as zipf:
          with zipf.open("archive", "r") as f:
              assert f.read() == targz
  
      from_list = _testing.list_to_archive(archive_spec.keys())
      with archive_path.open("wb") as f:
          f.write(from_list)
  
      with tarfile.open(str(archive_path)) as tarf:
          assert sorted(map(Path, tarf.getnames())) == sorted(
              list(map(Path, archive_spec.keys()))
              + [Path("."), Path("a"), Path("a", "b"), Path("data")]
          )
  
imports: import re
  import tarfile
  import zipfile
  from pathlib import Path
  import pytest
  import requests
  from nilearn import image
  from nilearn._utils.data_gen import generate_fake_fmri
  from nilearn.datasets.tests import _testing
label_desc: Use image node_id 10 for calling a global function with example usage: test_dict_to_archive(tmp_path) without return types