code: def pack_data(o, d, key_types=object):
      """Merge known data into tuple or dict
  
      Parameters
      ----------
      o
          core data structures containing literals and keys
      d : dict
          mapping of keys to data
  
      Examples
      --------
      >>> data = {'x': 1}
      >>> pack_data(('x', 'y'), data)
      (1, 'y')
      >>> pack_data({'a': 'x', 'b': 'y'}, data)  # doctest: +SKIP
      {'a': 1, 'b': 'y'}
      >>> pack_data({'a': ['x'], 'b': 'y'}, data)  # doctest: +SKIP
      {'a': [1], 'b': 'y'}
      """
      typ = type(o)
      try:
          if isinstance(o, key_types) and o in d:
              return d[o]
      except TypeError:
          pass
  
      if typ in collection_types:
          return typ([pack_data(x, d, key_types=key_types) for x in o])
      elif typ is dict:
          return {
              k: pack_data(v, d, key_types=key_types)
              for k, v in o.items()
          }
      elif is_namedtuple_instance(o):
          return _namedtuple_packing(
              o, partial(pack_data, d=d, key_types=key_types)
          )
      else:
          return o
  
imports: from __future__ import annotations
  import asyncio
  import logging
  import random
  from collections import defaultdict
  from collections.abc import Callable, Collection, Coroutine, Mapping
  from functools import partial
  from itertools import cycle
  from typing import Any, TypeVar
  from tlz import concat, drop, groupby, merge
  import dask.config
  from dask.optimization import SubgraphCallable
  from dask.typing import Key
  from dask.utils import is_namedtuple_instance, parse_timedelta
  from distributed.core import ConnectionPool, rpc
  from distributed.utils import All
label_desc: Use image node_id 4 for calling a global function with example usage: pack_data(o, d, key_types) and returns: typ, d, unknown, _namedtuple_packing, o