code: def overlap(x, depth, boundary, *, allow_rechunk=True):
      """Share boundaries between neighboring blocks
  
      Parameters
      ----------
  
      x: da.Array
          A dask array
      depth: dict
          The size of the shared boundary per axis
      boundary: dict
          The boundary condition on each axis. Options are 'reflect', 'periodic',
          'nearest', 'none', or an array value.  Such a value will fill the
          boundary with that value.
      allow_rechunk: bool, keyword only
          Allows rechunking, otherwise chunk sizes need to match and core
          dimensions are to consist only of one chunk.
  
      The depth input informs how many cells to overlap between neighboring
      blocks ``{0: 2, 2: 5}`` means share two cells in 0 axis, 5 cells in 2 axis.
      Axes missing from this input will not be overlapped.
  
      Any axis containing chunks smaller than depth will be rechunked if
      possible, provided the keyword ``allow_rechunk`` is True (recommended).
  
      Examples
      --------
      >>> import numpy as np
      >>> import dask.array as da
  
      >>> x = np.arange(64).reshape((8, 8))
      >>> d = da.from_array(x, chunks=(4, 4))
      >>> d.chunks
      ((4, 4), (4, 4))
  
      >>> g = da.overlap.overlap(d, depth={0: 2, 1: 1},
      ...                       boundary={0: 100, 1: 'reflect'})
      >>> g.chunks
      ((8, 8), (6, 6))
  
      >>> np.array(g)
      array([[100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
             [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
             [  0,   0,   1,   2,   3,   4,   3,   4,   5,   6,   7,   7],
             [  8,   8,   9,  10,  11,  12,  11,  12,  13,  14,  15,  15],
             [ 16,  16,  17,  18,  19,  20,  19,  20,  21,  22,  23,  23],
             [ 24,  24,  25,  26,  27,  28,  27,  28,  29,  30,  31,  31],
             [ 32,  32,  33,  34,  35,  36,  35,  36,  37,  38,  39,  39],
             [ 40,  40,  41,  42,  43,  44,  43,  44,  45,  46,  47,  47],
             [ 16,  16,  17,  18,  19,  20,  19,  20,  21,  22,  23,  23],
             [ 24,  24,  25,  26,  27,  28,  27,  28,  29,  30,  31,  31],
             [ 32,  32,  33,  34,  35,  36,  35,  36,  37,  38,  39,  39],
             [ 40,  40,  41,  42,  43,  44,  43,  44,  45,  46,  47,  47],
             [ 48,  48,  49,  50,  51,  52,  51,  52,  53,  54,  55,  55],
             [ 56,  56,  57,  58,  59,  60,  59,  60,  61,  62,  63,  63],
             [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
             [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]])
      """
      depth2 = coerce_depth(x.ndim, depth)
      boundary2 = coerce_boundary(x.ndim, boundary)
  
      depths = [
          max(d) if isinstance(d, tuple) else d for d in depth2.values()
      ]
      if allow_rechunk:
          # rechunk if new chunks are needed to fit depth in every chunk
          new_chunks = tuple(
              ensure_minimum_chunksize(size, c)
              for size, c in zip(depths, x.chunks)
          )
          x1 = x.rechunk(
              new_chunks
          )  # this is a no-op if x.chunks == new_chunks
  
      else:
          original_chunks_too_small = any(
              [min(c) < d for d, c in zip(depths, x.chunks)]
          )
          if original_chunks_too_small:
              raise ValueError(
                  "Overlap depth is larger than smallest chunksize.\n"
                  "Please set allow_rechunk=True to rechunk automatically.\n"
                  f"Overlap depths required: {depths}\n"
                  f"Input chunks: {x.chunks}\n"
              )
          x1 = x
  
      x2 = boundaries(x1, depth2, boundary2)
      x3 = overlap_internal(x2, depth2)
      trim = {
          k: v * 2 if boundary2.get(k, "none") != "none" else 0
          for k, v in depth2.items()
      }
      x4 = chunk.trim(x3, trim)
      return x4
  
imports: from __future__ import annotations
  import warnings
  from numbers import Integral, Number
  import numpy
  from tlz import concat, get, partial
  from tlz.curried import map
  from dask.array import chunk
  from dask.array.core import Array, concatenate, map_blocks, unify_chunks
  from dask.array.creation import empty_like, full_like
  from dask.array.numpy_compat import normalize_axis_tuple
  from dask.base import tokenize
  from dask.highlevelgraph import HighLevelGraph
  from dask.layers import ArrayOverlapLayer
  from dask.utils import derived_from
label_desc: Use image node_id 13 for calling a global function with example usage: overlap(x, depth, boundary) and returns: x4