code: def _solve(a, b):
      from cupy.linalg._util import (
          _assert_stacked_2d,
          _assert_stacked_square,
          linalg_common_type,
      )
  
      _commonType = functools.partial(
          linalg_common_type, reject_float16=False
      )
  
      _assert_stacked_2d(a)
      _assert_stacked_square(a)
      _, result_t = _commonType(a, b)
  
      if b.ndim == 1:
          # (M,) -> (M, 1)
          old_shape = b.shape
          b = b.reshape(-1, 1)
      elif b.ndim == a.ndim - 1:
          # x1 has shape (M, M) or (..., M, M)
          raise ValueError(
              "x2 must have shape (M,) or (..., M, K); "
              "(..., M) is not allowed"
          )
      else:
          # (..., M, K) => no change
          old_shape = None
  
      r = np.linalg.solve(a, b).astype(result_t, copy=False)
      r = r.reshape(old_shape) if old_shape else r
      return r
  
imports: from __future__ import annotations
  import functools
  from ._dtypes import _floating_dtypes, _numeric_dtypes
  from ._manipulation_functions import reshape
  from ._array_object import Array
  from .._core.internal import _normalize_axis_indices
  from typing import TYPE_CHECKING
  from typing import NamedTuple
  import cupy
label_desc: Use image node_id 17 for calling a global function with example usage: _solve(a, b) and returns: r