code: def idxs_take(idxs, vals, which):
      """
      Return `vals[which]` where `which` is a subset of `idxs`
      """
      # TODO: consider insisting on sorted idxs
      # TODO: use np.searchsorted instead of dct
      assert len(idxs) == len(vals)
      table = dict(list(zip(idxs, vals)))
      return np.asarray([table[w] for w in which])
  
imports: from __future__ import print_function
  from __future__ import absolute_import
  from builtins import str
  from builtins import zip
  from builtins import range
  from builtins import object
  import sys
  import numpy
  from .pyll import Apply
  from .pyll import as_apply
  from .pyll import dfs
  from .pyll import toposort
  from .pyll import scope
  from .pyll import stochastic
label_desc: Use image node_id 5 for calling a global function with example usage: idxs_take(idxs, vals, which) and returns: np