code: def _tensordot(a, b, a_axes, b_axes, c_axes=None):
      a_col_ndim = len(a_axes[1])
      b_row_ndim = len(b_axes[0])
      if a_col_ndim != b_row_ndim:
          raise ValueError("axes count mismatch")
      if a.ndim < a_col_ndim or b.ndim < b_row_ndim:
          raise ValueError(
              "dimension of input tensors must be "
              "greater equal to dot-axes count ({})".format(a_col_ndim)
          )
      for a_axis, b_axis in zip(a_axes[1], b_axes[0]):
          if a.shape[a_axis] != b.shape[b_axis]:
              raise ValueError("shape mismatch")
  
      xp = backend.get_array_module(a)
      y = xp.tensordot(a, b, axes=(tuple(a_axes[1]), tuple(b_axes[0])))
  
      if c_axes is not None:
          a_row_ndim = len(a_axes[0])
          b_col_ndim = len(b_axes[1])
          c_row_ndim = len(c_axes[0])
          c_col_ndim = len(c_axes[1])
          if a_row_ndim != c_row_ndim:
              raise ValueError("axes count mismatch")
          if b_col_ndim != c_col_ndim:
              raise ValueError("axes count mismatch")
  
          trans = [None for i in six.moves.range(y.ndim)]
          table_a = [
              1 if i in a_axes[0] else 0
              for i in six.moves.range(a.ndim)
          ]
          table_a = numpy.cumsum(table_a) - 1
          for i, c_axis in enumerate(c_axes[0]):
              trans[c_axis] = table_a[a_axes[0][i]]
          table_b = [
              1 if i in b_axes[1] else 0
              for i in six.moves.range(b.ndim)
          ]
          table_b = numpy.cumsum(table_b) - 1
          for i, c_axis in enumerate(c_axes[1]):
              trans[c_axis] = table_b[b_axes[1][i]] + len(a_axes[0])
          for i, c_axis in enumerate(trans):
              if i != c_axis:
                  y = xp.transpose(y, trans)
                  break
  
      return y
  
file_path: chainer/chainer/functions/math/tensordot.py
imports: import numpy
  import six
  from chainer import backend
  from chainer import function_node
  from chainer import utils
  from chainer.utils import collections_abc
  from chainer.utils import type_check
label_desc: Use image node_id 1 for calling a global function with example usage: _tensordot(a, b, a_axes, b_axes, c_axes) and returns: y