code: def issue_api_call(api_call, db, names_to_idxs, kb_text, babi):
      """
      Parse the api call and use it to search the database
      """
      desired_properties = api_call.strip().split(" ")[1:]
  
      if babi.task + 1 < 6:
          properties_order = [
              "R_cuisine",
              "R_location",
              "R_number",
              "R_price",
          ]
      else:
          properties_order = ["R_cuisine", "R_location", "R_price"]
  
      assert len(properties_order) == len(desired_properties)
  
      # Start result as all possible kb entries
      returned_kb_idxs = set(
          itertools.chain.from_iterable(names_to_idxs.values())
      )
  
      for ptype, prop in zip(properties_order, desired_properties):
          kb_idxs = [
              names_to_idxs[x.split(" ")[1]] for x in db[ptype][prop]
          ]
          kb_idxs = list(itertools.chain.from_iterable(kb_idxs))
          # iteratively perform intersection with subset that matches query
          returned_kb_idxs = returned_kb_idxs.intersection(kb_idxs)
  
      returned_kb_idxs = list(returned_kb_idxs)
      # Return actual text kb entries
      kb_results = list(kb_text[returned_kb_idxs])
      return kb_results
  
file_path: nlp-architect/examples/memn2n_dialogue/interactive_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import itertools
  from builtins import input
  from copy import copy
  from functools import reduce
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: issue_api_call(api_call, db, names_to_idxs, kb_text, babi) and returns: kb_results