code: def inline(dsk, keys=None, inline_constants=True, dependencies=None):
      """Return new dask with the given keys inlined with their values.
  
      Inlines all constants if ``inline_constants`` keyword is True. Note that
      the constant keys will remain in the graph, to remove them follow
      ``inline`` with ``cull``.
  
      Examples
      --------
      >>> def inc(x):
      ...     return x + 1
  
      >>> def add(x, y):
      ...     return x + y
  
      >>> d = {'x': 1, 'y': (inc, 'x'), 'z': (add, 'x', 'y')}
      >>> inline(d)       # doctest: +ELLIPSIS
      {'x': 1, 'y': (<function inc at ...>, 1), 'z': (<function add at ...>, 1, 'y')}
  
      >>> inline(d, keys='y') # doctest: +ELLIPSIS
      {'x': 1, 'y': (<function inc at ...>, 1), 'z': (<function add at ...>, 1, (<function inc at ...>, 1))}
  
      >>> inline(d, keys='y', inline_constants=False) # doctest: +ELLIPSIS
      {'x': 1, 'y': (<function inc at ...>, 'x'), 'z': (<function add at ...>, 'x', (<function inc at ...>, 'x'))}
      """
      if dependencies and isinstance(
          next(iter(dependencies.values())), list
      ):
          dependencies = {k: set(v) for k, v in dependencies.items()}
  
      keys = _flat_set(keys)
  
      if dependencies is None:
          dependencies = {k: get_dependencies(dsk, k) for k in dsk}
  
      if inline_constants:
          keys.update(
              k
              for k, v in dsk.items()
              if (ishashable(v) and v in dsk)
              or (not dependencies[k] and not istask(v))
          )
  
      # Keys may depend on other keys, so determine replace order with toposort.
      # The values stored in `keysubs` do not include other keys.
      replaceorder = toposort(
          {k: dsk[k] for k in keys if k in dsk},
          dependencies=dependencies,
      )
      keysubs = {}
      for key in replaceorder:
          val = dsk[key]
          for dep in keys & dependencies[key]:
              if dep in keysubs:
                  replace = keysubs[dep]
              else:
                  replace = dsk[dep]
              val = subs(val, dep, replace)
          keysubs[key] = val
  
      # Make new dask with substitutions
      dsk2 = keysubs.copy()
      for key, val in dsk.items():
          if key not in dsk2:
              for item in keys & dependencies[key]:
                  val = subs(val, item, keysubs[item])
              dsk2[key] = val
      return dsk2
  
imports: from __future__ import annotations
  import math
  import numbers
  import uuid
  from enum import Enum
  from dask import config, core, utils
  from dask.core import flatten, get_dependencies, ishashable, istask, reverse_dict, subs, toposort
label_desc: Use image node_id 5 for calling a global function with example usage: inline(dsk, keys, inline_constants, dependencies) and returns: dsk2