code: def fetch_atlas_aal(
      version="SPM12", data_dir=None, url=None, resume=True, verbose=1
  ):
      """Download and returns the AAL template for :term:`SPM` 12.
  
      This :term:`Deterministic atlas` is the result of an automated anatomical
      parcellation of the spatially normalized single-subject high-resolution
      T1 volume provided by the Montreal Neurological Institute (:term:`MNI`)
      (D. L. Collins et al., 1998, Trans. Med. Imag. 17, 463-468, PubMed).
  
      For more information on this dataset's structure,
      see :footcite:t:`AAL_atlas`,
      and :footcite:t:`Tzourio-Mazoyer2002`.
  
      .. warning::
  
          The maps image (``data.maps``) contains 117 unique integer values
          defining the parcellation. However, these values are not consecutive
          integers from 0 to 116 as is usually the case in Nilearn.
          Therefore, these values shouldn't be interpreted as indices for the
          list of label names. In addition, the region IDs are provided as
          strings, so it is necessary to cast them to integers when indexing.
  
      For example, to get the name of the region corresponding to the region
      ID 5021 in the image, you should do:
  
      .. code-block:: python
  
          # This should print 'Lingual_L'
          data.labels[data.indices.index("5021")]
  
      Conversely, to get the region ID corresponding to the label
      "Precentral_L", you should do:
  
      .. code-block:: python
  
          # This should print '2001'
          data.indices[data.labels.index("Precentral_L")]
  
      Parameters
      ----------
      version : {'SPM12', 'SPM5', 'SPM8'}, default='SPM12'
          The version of the AAL atlas. Must be 'SPM5', 'SPM8', or 'SPM12'.
      %(data_dir)s
      %(url)s
      %(resume)s
      %(verbose)s
  
      Returns
      -------
      data : :class:`sklearn.utils.Bunch`
          Dictionary-like object, keys are:
  
              - 'maps': :obj:`str`, path to nifti file containing the
                regions. The image has shape ``(91, 109, 91)`` and contains
                117 unique integer values defining the parcellation. Please
                refer to the main description to see how to link labels to
                regions IDs.
              - 'labels': :obj:`list` of :obj:`str`, list of the names of the
                regions. This list has 116 names as 'Background' (label 0) is
                not included in this list. Please refer to the main description
                to see how to link labels to regions IDs.
              - 'indices': :obj:`list` of :obj:`str`, indices mapping 'labels'
                to values in the 'maps' image. This list has 116 elements.
                Since the values in the 'maps' image do not correspond to
                indices in ``labels``, but rather to values in ``indices``, the
                location of a label in the ``labels`` list does not necessary
                match the associated value in the image. Use the ``indices``
                list to identify the appropriate image value for a given label
                (See main description above).
              - 'description': :obj:`str`, description of the atlas.
  
      References
      ----------
      .. footbibliography::
  
      Notes
      -----
      Licence: unknown.
  
      """
      versions = ["SPM5", "SPM8", "SPM12"]
      if version not in versions:
          raise ValueError(
              f"The version of AAL requested '{version}' does not exist."
              f"Please choose one among {versions}."
          )
  
      dataset_name = f"aal_{version}"
      opts = {"uncompress": True}
  
      if url is None:
          base_url = "https://www.gin.cnrs.fr/"
          if version == "SPM12":
              url = f"{base_url}AAL_files/aal_for_SPM12.tar.gz"
              basenames = ("AAL.nii", "AAL.xml")
              filenames = [
                  (os.path.join("aal", "atlas", f), url, opts)
                  for f in basenames
              ]
          else:
              url = (
                  f"{base_url}wp-content/uploads/aal_for_{version}.zip"
              )
              basenames = ("ROI_MNI_V4.nii", "ROI_MNI_V4.txt")
              filenames = [
                  (os.path.join(f"aal_for_{version}", f), url, opts)
                  for f in basenames
              ]
  
      data_dir = get_dataset_dir(
          dataset_name, data_dir=data_dir, verbose=verbose
      )
      atlas_img, labels_file = fetch_files(
          data_dir, filenames, resume=resume, verbose=verbose
      )
      fdescr = get_dataset_descr("aal_SPM12")
      labels = []
      indices = []
      if version == "SPM12":
          xml_tree = xml.etree.ElementTree.parse(labels_file)
          root = xml_tree.getroot()
          for label in root.iter("label"):
              indices.append(label.find("index").text)
              labels.append(label.find("name").text)
      else:
          with open(labels_file) as fp:
              for line in fp:
                  _, label, index = line.strip().split("\t")
                  indices.append(index)
                  labels.append(label)
          fdescr = fdescr.replace("SPM 12", version)
  
      params = {
          "description": fdescr,
          "maps": atlas_img,
          "labels": labels,
          "indices": indices,
      }
  
      return Bunch(**params)
  
imports: import json
  import os
  import re
  import shutil
  import warnings
  import xml.etree.ElementTree
  from pathlib import Path
  from tempfile import mkdtemp
  import nibabel
  import numpy
  import pandas
  from sklearn.utils import Bunch
  from .._utils import check_niimg, fill_doc
  from ..image import get_data, new_img_like, reorder_img
  from ._utils import fetch_files, get_dataset_descr, get_dataset_dir
label_desc: Use image node_id 14 for calling a global function with example usage: fetch_atlas_aal(version, data_dir, url, resume, verbose) and returns: Bunch