code: def _trim(x, axes, boundary, block_info):
      """Similar to dask.array.chunk.trim but requires one to specificy the
      boundary condition.
  
      ``axes``, and ``boundary`` are assumed to have been coerced.
  
      """
      axes = [axes.get(i, 0) for i in range(x.ndim)]
      axes_front = (
          ax[0] if isinstance(ax, tuple) else ax for ax in axes
      )
      axes_back = (
          -ax[1]
          if isinstance(ax, tuple) and ax[1]
          else -ax
          if isinstance(ax, Integral) and ax
          else None
          for ax in axes
      )
  
      trim_front = (
          0
          if (chunk_location == 0 and boundary.get(i, "none") == "none")
          else ax
          for i, (chunk_location, ax) in enumerate(
              zip(block_info[0]["chunk-location"], axes_front)
          )
      )
      trim_back = (
          None
          if (
              chunk_location == chunks - 1
              and boundary.get(i, "none") == "none"
          )
          else ax
          for i, (chunks, chunk_location, ax) in enumerate(
              zip(
                  block_info[0]["num-chunks"],
                  block_info[0]["chunk-location"],
                  axes_back,
              )
          )
      )
      ind = tuple(
          slice(front, back)
          for front, back in zip(trim_front, trim_back)
      )
      return x[ind]
  
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 5 for calling a global function with example usage: _trim(x, axes, boundary, block_info) and returns: x