code: def tensorsolve(a, b, axes=None):
      """Solves tensor equations denoted by ``ax = b``.
  
      Suppose that ``b`` is equivalent to ``cupy.tensordot(a, x)``.
      This function computes tensor ``x`` from ``a`` and ``b``.
  
      Args:
          a (cupy.ndarray): The tensor with ``len(shape) >= 1``
          b (cupy.ndarray): The tensor with ``len(shape) >= 1``
          axes (tuple of ints): Axes in ``a`` to reorder to the right
              before inversion.
  
      Returns:
          cupy.ndarray:
              The tensor with shape ``Q`` such that ``b.shape + Q == a.shape``.
  
      .. warning::
          This function calls one or more cuSOLVER routine(s) which may yield
          invalid results if input conditions are not met.
          To detect these invalid results, you can set the `linalg`
          configuration to a value that is not `ignore` in
          :func:`cupyx.errstate` or :func:`cupyx.seterr`.
  
      .. seealso:: :func:`numpy.linalg.tensorsolve`
      """
      if axes is not None:
          allaxes = list(range(a.ndim))
          for k in axes:
              allaxes.remove(k)
              allaxes.insert(a.ndim, k)
          a = a.transpose(allaxes)
  
      oldshape = a.shape[-(a.ndim - b.ndim) :]
      prod = internal.prod(oldshape)
  
      a = a.reshape(-1, prod)
      b = b.ravel()
      result = solve(a, b)
      return result.reshape(oldshape)
  
file_path: cupy/cupy/linalg/_solve.py
imports: import warnings
  import numpy
  from numpy import linalg
  import cupy
  from cupy._core import internal
  from cupy.cuda import device
  from cupy.linalg import _decomposition
  from cupy.linalg import _util
  import cupyx
label_desc: Use image node_id 2 for calling a global function with example usage: tensorsolve(a, b, axes) and returns: result