code: def test_trace():
      def _assert(a, b, *args, **kwargs):
          return assert_eq(
              a.trace(*args, **kwargs), b.trace(*args, **kwargs)
          )
  
      b = np.arange(12).reshape((3, 4))
      a = da.from_array(b, 1)
      _assert(a, b)
      _assert(a, b, 0)
      _assert(a, b, 1)
      _assert(a, b, -1)
  
      b = np.arange(8).reshape((2, 2, 2))
      a = da.from_array(b, 2)
      _assert(a, b)
      _assert(a, b, 0)
      _assert(a, b, 1)
      _assert(a, b, -1)
      _assert(a, b, 0, 0, 1)
      _assert(a, b, 0, 0, 2)
      _assert(a, b, 0, 1, 2, int)
      _assert(a, b, 0, 1, 2, float)
      _assert(a, b, offset=1, axis1=0, axis2=2, dtype=int)
      _assert(a, b, offset=1, axis1=0, axis2=2, dtype=float)
  
imports: from __future__ import annotations
  import os
  import warnings
  from contextlib import nullcontext
  from itertools import permutations, zip_longest
  import pytest
  import itertools
  import dask.array
  import dask.config
  from dask.array.numpy_compat import ComplexWarning, _numpy_122
  from dask.array.utils import assert_eq, same_keys
  from dask.core import get_deps
label_desc: Use image node_id 36 for calling a global function with example usage: test_trace() and returns: assert_eq