code: def _execute_task(arg, cache):
      """Do the actual work of collecting data and executing a function.
  
      Examples
      --------
      >>> from flash.core.serve.dag.utils_test import add, inc
      >>> cache = {'x': 1, 'y': 2}  # Compute tasks against a cache
      >>> _execute_task((add, 'x', 1), cache)  # Compute task in naive manner
      2
      >>> _execute_task((add, (inc, 'x'), 1), cache)  # Support nested computation
      3
      >>> _execute_task('x', cache)  # Also grab data from cache
      1
      >>> list(_execute_task(['x', 'y'], cache))  # Support nested lists
      [1, 2]
      >>> list(map(list, _execute_task([['x', 'y'], ['y', 'x']], cache)))
      [[1, 2], [2, 1]]
      >>> _execute_task('foo', cache)  # Passes through on non-keys
      'foo'
  
      """
      if isinstance(arg, list):
          return [_execute_task(a, cache) for a in arg]
      if istask(arg):
          func, args = arg[0], arg[1:]
          # Note: Don't assign the subtask results to a variable. numpy detects
          # temporaries by their reference count and can execute certain
          # operations in-place.
          return func(*(_execute_task(a, cache) for a in args))
      if not ishashable(arg):
          return arg
      if arg in cache:
          return cache[arg]
      return arg
  
imports: from collections import defaultdict
  from typing import List, Sequence
  from flash.core.utilities.imports import _TOPIC_SERVE_AVAILABLE
label_desc: Use image node_id 5 for calling a global function with example usage: _execute_task(arg, cache) and returns: arg, unknown, func, arg, cache