code: def get_data(url, gallery_dir):
      """Persistent dictionary usage to retrieve the search indexes"""
  
      # shelve keys need to be str in python 2
      if sys.version_info[0] == 2 and isinstance(url, unicode):
          url = url.encode("utf-8")
  
      cached_file = os.path.join(gallery_dir, "searchindex")
      search_index = shelve.open(cached_file)
      if url in search_index:
          data = search_index[url]
      else:
          data = _get_data(url)
          search_index[url] = data
      search_index.close()
  
      return data
  
imports: from __future__ import print_function
  import codecs
  import gzip
  import os
  import posixpath
  import re
  import shelve
  import sys
  from io import StringIO
  from .None import sphinx_compatibility
label_desc: Use image node_id 2 for calling a global function with example usage: get_data(url, gallery_dir) and returns: data