code: def tensordot(a, b, axes=2):
      """Returns the tensor dot product of two arrays along specified axes.
  
      This is equivalent to compute dot product along the specified axes which
      are treated as one axis by reshaping.
  
      Args:
          a (cupy.ndarray): The first argument.
          b (cupy.ndarray): The second argument.
          axes:
              - If it is an integer, then ``axes`` axes at the last of ``a`` and
                the first of ``b`` are used.
              - If it is a pair of sequences of integers, then these two
                sequences specify the list of axes for ``a`` and ``b``. The
                corresponding axes are paired for sum-product.
  
      Returns:
          cupy.ndarray: The tensor dot product of ``a`` and ``b`` along the
          axes specified by ``axes``.
  
      .. seealso:: :func:`numpy.tensordot`
  
      """
      a_ndim = a.ndim
      b_ndim = b.ndim
      if a_ndim == 0 or b_ndim == 0:
          if axes != 0 and axes != ((), ()):
              raise ValueError(
                  "An input is zero-dim while axes has dimensions"
              )
          return cupy.multiply(a, b)
  
      if isinstance(axes, collections.abc.Sequence):
          if len(axes) != 2:
              raise ValueError("Axes must consist of two arrays.")
          a_axes, b_axes = axes
          if numpy.isscalar(a_axes):
              a_axes = (a_axes,)
          if numpy.isscalar(b_axes):
              b_axes = (b_axes,)
      else:
          a_axes = tuple(range(a_ndim - axes, a_ndim))
          b_axes = tuple(range(axes))
  
      sum_ndim = len(a_axes)
      if sum_ndim != len(b_axes):
          raise ValueError("Axes length mismatch")
  
      for a_axis, b_axis in zip(a_axes, b_axes):
          if a.shape[a_axis] != b.shape[b_axis]:
              raise ValueError("Axis dimension mismatch")
  
      # Make the axes non-negative
      a = _move_axes_to_head(a, [axis % a_ndim for axis in a_axes])
      b = _move_axes_to_head(b, [axis % b_ndim for axis in b_axes])
  
      ret_shape = a.shape[sum_ndim:] + b.shape[sum_ndim:]
  
      k = internal.prod(a.shape[:sum_ndim])
      # Avoid division by zero: _core.tensordot_core returns zeros without
      # checking n, m consistency, thus allowing 0-length dimensions to work
      n = a.size // k if k != 0 else 0
      m = b.size // k if k != 0 else 0
  
      return _core.tensordot_core(a, b, None, n, m, k, ret_shape)
  
file_path: cupy/cupy/linalg/_product.py
imports: import collections.abc
  import numbers
  import numpy
  import cupy
  from cupy import _core
  from cupy._core import internal
  from cupy._core._gufuncs import _GUFunc
  from cupy.linalg import _solve
  from cupy.linalg import _util
label_desc: Use image node_id 6 for calling a global function with example usage: tensordot(a, b, axes) and returns: _core, cupy