code: def solve(a, b, no_crash=False):
      """Solve a linear system.
  
      Parameters
      ----------
      a : :class:`.NDArrayNumericExpression`, (N, N)
          Coefficient matrix.
      b : :class:`.NDArrayNumericExpression`, (N,) or (N, K)
          Dependent variables.
  
      Returns
      -------
      :class:`.NDArrayNumericExpression`, (N,) or (N, K)
          Solution to the system Ax = B. Shape is same as shape of B.
  
      """
      b_ndim_orig = b.ndim
      a, b = solve_helper(a, b, b_ndim_orig)
      if no_crash:
          name = "linear_solve_no_crash"
          return_type = hl.tstruct(
              solution=hl.tndarray(hl.tfloat64, 2), failed=hl.tbool
          )
      else:
          name = "linear_solve"
          return_type = hl.tndarray(hl.tfloat64, 2)
  
      indices, aggregations = unify_all(a, b)
      ir = Apply(name, return_type, a._ir, b._ir)
      result = construct_expr(ir, return_type, indices, aggregations)
  
      if b_ndim_orig == 1:
          if no_crash:
              result = hl.struct(
                  solution=result.solution.reshape((-1)),
                  failed=result.failed,
              )
          else:
              result = result.reshape((-1))
      return result
  
imports: from functools import reduce
  import hail
  from hail.expr.functions import _ndarray
  from hail.expr.functions import array
  from hail.expr.types import HailType, tfloat64, tfloat32, ttuple, tndarray
  from hail.typecheck import typecheck, nullable, oneof, tupleof, sequenceof
  from hail.expr.expressions import expr_int32, expr_int64, expr_tuple, expr_any, expr_array, expr_ndarray, expr_numeric, Int64Expression, cast_expr, construct_expr, expr_bool, unify_all
  from hail.expr.expressions.typed_expressions import NDArrayNumericExpression
  from hail.ir import NDArrayQR, NDArrayInv, NDArrayConcat, NDArraySVD, NDArrayEigh, Apply
label_desc: Use image node_id 8 for calling a global function with example usage: solve(a, b, no_crash) and returns: result