code: def encode(a):
      """Base64 encode a numpy array."""
      try:
          data = a.tobytes()
      except AttributeError:
          # np < 1.9
          data = a.tostring()
      return base64.b64encode(data).decode("utf-8")
  
file_path: nilearn/nilearn/plotting/js_plotting_utils.py
imports: import base64
  import os
  import warnings
  from string import Template
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from nilearn.plotting.html_document import HTMLDocument, set_max_img_views_before_warning
  from ..None import surface
  from .._utils.extmath import fast_abs_percentile
  from .._utils.param_validation import check_threshold
label_desc: Use image node_id 4 for calling a global function with example usage: encode(a) and returns: base64