code: def _tensordot(a, b, axes=2):
      # Much of this is stolen from numpy/core/numeric.py::tensordot
      # Please see license at https://github.com/numpy/numpy/blob/master/LICENSE.txt
      try:
          iter(axes)
      except TypeError:
          axes_a = list(range(-axes, 0))
          axes_b = list(range(0, axes))
      else:
          axes_a, axes_b = axes
      try:
          na = len(axes_a)
          axes_a = list(axes_a)
      except TypeError:
          axes_a = [axes_a]
          na = 1
      try:
          nb = len(axes_b)
          axes_b = list(axes_b)
      except TypeError:
          axes_b = [axes_b]
          nb = 1
  
      # a, b = asarray(a), asarray(b)  # <--- modified
      as_ = a.shape
      nda = a.ndim
      bs = b.shape
      ndb = b.ndim
      equal = True
      if na != nb:
          equal = False
      else:
          for k in range(na):
              if as_[axes_a[k]] != bs[axes_b[k]]:
                  equal = False
                  break
              if axes_a[k] < 0:
                  axes_a[k] += nda
              if axes_b[k] < 0:
                  axes_b[k] += ndb
      if not equal:
          raise ValueError("shape-mismatch for sum")
  
      # Move the axes to sum over to the end of "a"
      # and to the front of "b"
      notin = [k for k in range(nda) if k not in axes_a]
      newaxes_a = notin + axes_a
      N2 = 1
      for axis in axes_a:
          N2 *= as_[axis]
      newshape_a = (-1, N2)
      olda = [as_[axis] for axis in notin]
  
      notin = [k for k in range(ndb) if k not in axes_b]
      newaxes_b = axes_b + notin
      N2 = 1
      for axis in axes_b:
          N2 *= bs[axis]
      newshape_b = (N2, -1)
      oldb = [bs[axis] for axis in notin]
  
      at = a.transpose(newaxes_a).reshape(newshape_a)
      bt = b.transpose(newaxes_b).reshape(newshape_b)
      res = np.ma.dot(at, bt)
      return res.reshape(olda + oldb)
  
imports: from __future__ import annotations
  import math
  import numpy
  from dask.array import chunk
  from dask.array.core import Array
  from dask.array.dispatch import concatenate_lookup, divide_lookup, einsum_lookup, empty_lookup, nannumel_lookup, numel_lookup, percentile_lookup, tensordot_lookup, to_cupy_dispatch, to_numpy_dispatch
  from dask.array.numpy_compat import divide
  from dask.array.numpy_compat import ma_divide
  from dask.array.percentile import _percentile
  from dask.backends import CreationDispatch, DaskBackendEntrypoint
label_desc: Use image node_id 3 for calling a global function with example usage: _tensordot(a, b, axes) and returns: res