code: def tensorsolve(
      x1: Union[ivy.Array, ivy.NativeArray],
      x2: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      axes: Union[int, Tuple[List[int], List[int]]] = 2,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      ndim1 = ivy.get_num_dims(x1)
      ndim2 = ivy.get_num_dims(x2)
  
      if axes is not None:
          allaxes = list(range(0, ndim1))
          for k in axes:
              allaxes.remove(k)
              allaxes.insert(ndim1, k)
  
          x1 = ivy.matrix_transpose(x1)
  
      old_shape = x1.shape[-(ndim1 - ndim2) :]
  
      prod = 1
      for k in old_shape:
          prod *= k
  
      if ivy.shape(ivy.flatten(x1))[0] != prod**2:
          raise ivy.utils.exceptions.IvyException(
              "Input arrays must satisfy the requirement "
              "prod(x1.shape[x2.ndim:]) == prod(x1.shape[:x2.ndim])"
          )
  
      x1 = ivy.reshape(x1, (prod, prod))
      x2 = ivy.flatten(x2)
      res = ivy.solve(x1, x2)
      res = ivy.reshape(res, old_shape)
      return res
  
imports: from typing import Union, Optional, Tuple, Literal, List, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, to_native_arrays_and_back, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 30 for calling a global function with example usage: tensorsolve() and returns: res