code: def fetch_hcp_mmp_parcellation(
      subjects_dir=None, combine=True, *, accept=False, verbose=None
  ):
      """Fetch the HCP-MMP parcellation.
  
      This will download and install the HCP-MMP parcellation
      :footcite:`GlasserEtAl2016` files for FreeSurfer's fsaverage
      :footcite:`Mills2016` to the specified directory.
  
      Parameters
      ----------
      subjects_dir : path-like | None
          The subjects directory to use. The file will be placed in
          ``subjects_dir + '/fsaverage/label'``.
      combine : bool
          If True, also produce the combined/reduced set of 23 labels per
          hemisphere as ``HCPMMP1_combined.annot``
          :footcite:`GlasserEtAl2016supp`.
      %(accept)s
      %(verbose)s
  
      Notes
      -----
      Use of this parcellation is subject to terms of use on the
      `HCP-MMP webpage <https://balsa.wustl.edu/WN56>`_.
  
      References
      ----------
      .. footbibliography::
      """
      import pooch
  
      subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
      destination = subjects_dir / "fsaverage" / "label"
      fnames = [
          destination / f"{hemi}.HCPMMP1.annot" for hemi in ("lh", "rh")
      ]
      urls = dict(
          lh="https://ndownloader.figshare.com/files/5528816",
          rh="https://ndownloader.figshare.com/files/5528819",
      )
      hashes = dict(
          lh="46a102b59b2fb1bb4bd62d51bf02e975",
          rh="75e96b331940227bbcb07c1c791c2463",
      )
      if not all(fname.exists() for fname in fnames):
          if accept or "--accept-hcpmmp-license" in sys.argv:
              answer = "y"
          else:
              answer = _safe_input(
                  "%s\nAgree (y/[n])? " % _hcp_mmp_license_text
              )
          if answer.lower() != "y":
              raise RuntimeError(
                  "You must agree to the license to use this " "dataset"
              )
      downloader = pooch.HTTPDownloader(**_downloader_params())
      for hemi, fpath in zip(("lh", "rh"), fnames):
          if not op.isfile(fpath):
              fname = fpath.name
              pooch.retrieve(
                  url=urls[hemi],
                  known_hash=f"md5:{hashes[hemi]}",
                  path=destination,
                  downloader=downloader,
                  fname=fname,
              )
  
      if combine:
          fnames = [
              op.join(destination, "%s.HCPMMP1_combined.annot" % hemi)
              for hemi in ("lh", "rh")
          ]
          if all(op.isfile(fname) for fname in fnames):
              return
          # otherwise, let's make them
          logger.info("Creating combined labels")
          groups = OrderedDict(
              [
                  ("Primary Visual Cortex (V1)", ("V1",)),
                  ("Early Visual Cortex", ("V2", "V3", "V4")),
                  (
                      "Dorsal Stream Visual Cortex",
                      ("V3A", "V3B", "V6", "V6A", "V7", "IPS1"),
                  ),
                  (
                      "Ventral Stream Visual Cortex",
                      (
                          "V8",
                          "VVC",
                          "PIT",
                          "FFC",
                          "VMV1",
                          "VMV2",
                          "VMV3",
                      ),
                  ),
                  (
                      "MT+ Complex and Neighboring Visual Areas",
                      (
                          "V3CD",
                          "LO1",
                          "LO2",
                          "LO3",
                          "V4t",
                          "FST",
                          "MT",
                          "MST",
                          "PH",
                      ),
                  ),
                  (
                      "Somatosensory and Motor Cortex",
                      ("4", "3a", "3b", "1", "2"),
                  ),
                  (
                      "Paracentral Lobular and Mid Cingulate Cortex",
                      (
                          "24dd",
                          "24dv",
                          "6mp",
                          "6ma",
                          "SCEF",
                          "5m",
                          "5L",
                          "5mv",
                      ),
                  ),
                  (
                      "Premotor Cortex",
                      ("55b", "6d", "6a", "FEF", "6v", "6r", "PEF"),
                  ),
                  (
                      "Posterior Opercular Cortex",
                      ("43", "FOP1", "OP4", "OP1", "OP2-3", "PFcm"),
                  ),
                  (
                      "Early Auditory Cortex",
                      ("A1", "LBelt", "MBelt", "PBelt", "RI"),
                  ),
                  (
                      "Auditory Association Cortex",
                      (
                          "A4",
                          "A5",
                          "STSdp",
                          "STSda",
                          "STSvp",
                          "STSva",
                          "STGa",
                          "TA2",
                      ),
                  ),
                  (
                      "Insular and Frontal Opercular Cortex",
                      (
                          "52",
                          "PI",
                          "Ig",
                          "PoI1",
                          "PoI2",
                          "FOP2",
                          "FOP3",
                          "MI",
                          "AVI",
                          "AAIC",
                          "Pir",
                          "FOP4",
                          "FOP5",
                      ),
                  ),
                  (
                      "Medial Temporal Cortex",
                      (
                          "H",
                          "PreS",
                          "EC",
                          "PeEc",
                          "PHA1",
                          "PHA2",
                          "PHA3",
                      ),
                  ),
                  (
                      "Lateral Temporal Cortex",
                      (
                          "PHT",
                          "TE1p",
                          "TE1m",
                          "TE1a",
                          "TE2p",
                          "TE2a",
                          "TGv",
                          "TGd",
                          "TF",
                      ),
                  ),
                  (
                      "Temporo-Parieto-Occipital Junction",
                      (
                          "TPOJ1",
                          "TPOJ2",
                          "TPOJ3",
                          "STV",
                          "PSL",
                      ),
                  ),
                  (
                      "Superior Parietal Cortex",
                      (
                          "LIPv",
                          "LIPd",
                          "VIP",
                          "AIP",
                          "MIP",
                          "7PC",
                          "7AL",
                          "7Am",
                          "7PL",
                          "7Pm",
                      ),
                  ),
                  (
                      "Inferior Parietal Cortex",
                      (
                          "PGp",
                          "PGs",
                          "PGi",
                          "PFm",
                          "PF",
                          "PFt",
                          "PFop",
                          "IP0",
                          "IP1",
                          "IP2",
                      ),
                  ),
                  (
                      "Posterior Cingulate Cortex",
                      (
                          "DVT",
                          "ProS",
                          "POS1",
                          "POS2",
                          "RSC",
                          "v23ab",
                          "d23ab",
                          "31pv",
                          "31pd",
                          "31a",
                          "23d",
                          "23c",
                          "PCV",
                          "7m",
                      ),
                  ),
                  (
                      "Anterior Cingulate and Medial Prefrontal Cortex",
                      (
                          "33pr",
                          "p24pr",
                          "a24pr",
                          "p24",
                          "a24",
                          "p32pr",
                          "a32pr",
                          "d32",
                          "p32",
                          "s32",
                          "8BM",
                          "9m",
                          "10v",
                          "10r",
                          "25",
                      ),
                  ),
                  (
                      "Orbital and Polar Frontal Cortex",
                      (
                          "47s",
                          "47m",
                          "a47r",
                          "11l",
                          "13l",
                          "a10p",
                          "p10p",
                          "10pp",
                          "10d",
                          "OFC",
                          "pOFC",
                      ),
                  ),
                  (
                      "Inferior Frontal Cortex",
                      (
                          "44",
                          "45",
                          "IFJp",
                          "IFJa",
                          "IFSp",
                          "IFSa",
                          "47l",
                          "p47r",
                      ),
                  ),
                  (
                      "DorsoLateral Prefrontal Cortex",
                      (
                          "8C",
                          "8Av",
                          "i6-8",
                          "s6-8",
                          "SFL",
                          "8BL",
                          "9p",
                          "9a",
                          "8Ad",
                          "p9-46v",
                          "a9-46v",
                          "46",
                          "9-46d",
                      ),
                  ),
                  ("???", ("???",)),
              ]
          )
          assert len(groups) == 23
          labels_out = list()
  
          for hemi in ("lh", "rh"):
              labels = read_labels_from_annot(
                  "fsaverage",
                  "HCPMMP1",
                  hemi=hemi,
                  subjects_dir=subjects_dir,
                  sort=False,
              )
              label_names = [
                  "???"
                  if label.name.startswith("???")
                  else label.name.split("_")[1]
                  for label in labels
              ]
              used = np.zeros(len(labels), bool)
              for key, want in groups.items():
                  assert "\t" not in key
                  these_labels = [
                      li
                      for li, label_name in enumerate(label_names)
                      if label_name in want
                  ]
                  assert not used[these_labels].any()
                  assert len(these_labels) == len(want)
                  used[these_labels] = True
                  these_labels = [labels[li] for li in these_labels]
                  # take a weighted average to get the color
                  # (here color == task activation)
                  w = np.array(
                      [len(label.vertices) for label in these_labels]
                  )
                  w = w / float(w.sum())
                  color = np.dot(
                      w, [label.color for label in these_labels]
                  )
                  these_labels = sum(
                      these_labels,
                      Label([], subject="fsaverage", hemi=hemi),
                  )
                  these_labels.name = key
                  these_labels.color = color
                  labels_out.append(these_labels)
              assert used.all()
          assert len(labels_out) == 46
          for hemi, side in (("lh", "left"), ("rh", "right")):
              table_name = f"./{side}.fsaverage164.label.gii"
              write_labels_to_annot(
                  labels_out,
                  "fsaverage",
                  "HCPMMP1_combined",
                  hemi=hemi,
                  subjects_dir=subjects_dir,
                  sort=False,
                  table_name=table_name,
              )
  
imports: import importlib
  import inspect
  import logging
  import os
  import os.path
  import sys
  import tempfile
  import time
  import zipfile
  from collections import OrderedDict
  from pathlib import Path
  import numpy
  from ..label import Label, read_labels_from_annot, write_labels_to_annot
  from ..utils import _pl, _safe_input, _validate_type, get_config, get_subjects_dir, logger, set_config, verbose
  from ..utils.docs import _docformat, docdict
  from .config import MNE_DATASETS, _hcp_mmp_license_text
label_desc: Use image node_id 10 for calling a global function with example usage: fetch_hcp_mmp_parcellation(subjects_dir, combine) without return types