code: def expr_to_fn_of_stream_contents(expr, nkdims):
      def eval_expr(expr, kdim_values, stream_values):
          if isinstance(expr, Expr):
              fn = expr.fn
              args = [
                  eval_expr(arg, kdim_values, stream_values)
                  for arg in expr.args
              ]
              kwargs_list = [
                  eval_expr(kwarg, kdim_values, stream_values)
                  for kwarg in expr.kwargs
              ]
              kwargs = {}
              for kwargs_el in kwargs_list:
                  kwargs.update(
                      **eval_expr(kwargs_el, kdim_values, stream_values)
                  )
              # For a ParameterizedFunction (e.g. an Operation), drop keys that are not
              # accepted as params to avoid warnings
              if isinstance(fn, param.ParameterizedFunction):
                  kwargs = {
                      k: v for k, v in kwargs.items() if k in fn.param
                  }
              return fn(*args, **kwargs)
          elif isinstance(expr, StreamIndex):
              return stream_values[expr.index]
          elif isinstance(expr, KDimIndex):
              return kdim_values[expr.index]
          elif isinstance(expr, dict):
              return {
                  k: eval_expr(v, kdim_values, stream_values)
                  for k, v in expr.items()
              }
          elif isinstance(expr, (list, tuple)):
              return type(expr)(
                  [
                      eval_expr(v, kdim_values, stream_values)
                      for v in expr
                  ]
              )
          else:
              return expr
  
      def expr_fn(*args):
          kdim_values = args[:nkdims]
          stream_values = args[nkdims:]
          return eval_expr(expr, kdim_values, stream_values)
  
      return expr_fn
  
file_path: holoviews/holoviews/core/decollate.py
imports: from collections import namedtuple
  import param
  from ..None import Callable, DynamicMap, Element, GridSpace, HoloMap, Layout, NdOverlay, Overlay
  from ..plotting.util import initialize_dynamic
  from ..streams import Derived, Stream
  from .None import AdjointLayout, ViewableTree
  from .operation import OperationCallable
label_desc: Use image node_id 2 for calling a global function with example usage: expr_to_fn_of_stream_contents(expr, nkdims) and returns: expr_fn, eval_expr, fn, stream_values, kdim_values, unknown, type, expr