code: def _data_to_sprite(data):
      """Convert a 3D array into a sprite of sagittal slices.
  
      Parameters
      ----------
      data : Numpy array
          Input data to convert to sprite.
  
      Returns
      -------
      sprite : 2D numpy array
          If each sagittal slice is nz (height) x ny (width) pixels, the sprite
          size is (M x nz) x (N x ny), where M and N are computed to be roughly
          equal. All slices are pasted together row by row, from top left to
          bottom right. The last row is completed with empty slices.
  
      """
      nx, ny, nz = data.shape
      nrows = int(np.ceil(np.sqrt(nx)))
      ncolumns = int(np.ceil(nx / float(nrows)))
  
      sprite = np.zeros((nrows * nz, ncolumns * ny))
      indrow, indcol = np.where(np.ones((nrows, ncolumns)))
  
      for xx in range(nx):
          # we need to flip the image in the x axis
          sprite[
              (indrow[xx] * nz) : ((indrow[xx] + 1) * nz),
              (indcol[xx] * ny) : ((indcol[xx] + 1) * ny),
          ] = data[xx, :, ::-1].transpose()
  
      return sprite
  
imports: import copy
  import json
  import os
  import warnings
  from base64 import b64encode
  from io import BytesIO
  import matplotlib
  import numpy
  from matplotlib.image import imsave
  from nibabel.affines import apply_affine
  from nilearn.plotting.html_document import HTMLDocument
  from .._utils import fill_doc
  from .._utils.extmath import fast_abs_percentile
  from .._utils.niimg import safe_get_data
  from .._utils.niimg_conversions import check_niimg_3d
  from .._utils.param_validation import check_threshold
  from ..datasets import load_mni152_template
  from ..image import get_data, new_img_like, reorder_img, resample_to_img
  from ..plotting import cm
  from ..plotting.find_cuts import find_xyz_cut_coords
  from ..plotting.img_plotting import load_anat
  from .js_plotting_utils import colorscale, get_html_template
label_desc: Use image node_id 1 for calling a global function with example usage: _data_to_sprite(data) and returns: sprite