code: def test_ndarray_matmul():
      np_v = np.array([1, 2])
      np_y = np.array([1, 1, 1])
      np_m = np.array([[1, 2], [3, 4]])
      np_m_f32 = np_m.astype(np.float32)
      np_m_f64 = np_m.astype(np.float64)
      np_r = np.array([[1, 2, 3], [4, 5, 6]])
      np_r_f32 = np_r.astype(np.float32)
      np_r_f64 = np_r.astype(np.float64)
      np_cube = np.arange(8).reshape((2, 2, 2))
      np_rect_prism = np.arange(12).reshape((3, 2, 2))
      np_broadcasted_mat = np.arange(4).reshape((1, 2, 2))
      np_six_dim_tensor = np.arange(3 * 7 * 1 * 9 * 4 * 5).reshape(
          (3, 7, 1, 9, 4, 5)
      )
      np_five_dim_tensor = np.arange(7 * 5 * 1 * 5 * 3).reshape(
          (7, 5, 1, 5, 3)
      )
      np_ones_int32 = np.ones((4, 4), dtype=np.int32)
      np_ones_float64 = np.ones((4, 4), dtype=np.float64)
      np_zero_by_four = np.array([], dtype=np.float64).reshape((0, 4))
  
      v = hl.nd.array(np_v)
      y = hl.nd.array(np_y)
      m = hl.nd.array(np_m)
      m_f32 = hl.nd.array(np_m_f32)
      m_f64 = hl.nd.array(np_m_f64)
      r = hl.nd.array(np_r)
      r_f32 = hl.nd.array(np_r_f32)
      r_f64 = hl.nd.array(np_r_f64)
      cube = hl.nd.array(np_cube)
      rect_prism = hl.nd.array(np_rect_prism)
      broadcasted_mat = hl.nd.array(np_broadcasted_mat)
      six_dim_tensor = hl.nd.array(np_six_dim_tensor)
      five_dim_tensor = hl.nd.array(np_five_dim_tensor)
      ones_int32 = hl.nd.array(np_ones_int32)
      ones_float64 = hl.nd.array(np_ones_float64)
      zero_by_four = hl.nd.array(np_zero_by_four)
  
      assert_ndarrays_eq(
          (v @ v, np_v @ np_v),
          (m @ m, np_m @ np_m),
          (m_f32 @ m_f32, np_m_f32 @ np_m_f32),
          (m_f64 @ m_f64, np_m_f64 @ np_m_f64),
          (m @ m.T, np_m @ np_m.T),
          (m_f64 @ m_f64.T, np_m_f64 @ np_m_f64.T),
          (r @ r.T, np_r @ np_r.T),
          (r_f32 @ r_f32.T, np_r_f32 @ np_r_f32.T),
          (r_f64 @ r_f64.T, np_r_f64 @ np_r_f64.T),
          (v @ m, np_v @ np_m),
          (m @ v, np_m @ np_v),
          (v @ r, np_v @ np_r),
          (r @ y, np_r @ np_y),
          (cube @ cube, np_cube @ np_cube),
          (cube @ v, np_cube @ np_v),
          (v @ cube, np_v @ np_cube),
          (cube @ m, np_cube @ np_m),
          (m @ cube, np_m @ np_cube),
          (rect_prism @ m, np_rect_prism @ np_m),
          (m @ rect_prism, np_m @ np_rect_prism),
          (m @ rect_prism.T, np_m @ np_rect_prism.T),
          (
              broadcasted_mat @ rect_prism,
              np_broadcasted_mat @ np_rect_prism,
          ),
          (
              six_dim_tensor @ five_dim_tensor,
              np_six_dim_tensor @ np_five_dim_tensor,
          ),
          (
              zero_by_four @ ones_float64,
              np_zero_by_four,
              np_ones_float64,
          ),
          (
              zero_by_four.transpose() @ zero_by_four,
              np_zero_by_four.transpose() @ np_zero_by_four,
          ),
      )
  
      assert (
          hl.eval(
              hl.missing(hl.tndarray(hl.tfloat64, 2))
              @ hl.missing(hl.tndarray(hl.tfloat64, 2))
          )
          is None
      )
      assert (
          hl.eval(
              hl.missing(hl.tndarray(hl.tint64, 2))
              @ hl.nd.array(np.arange(10).reshape(5, 2))
          )
          is None
      )
      assert (
          hl.eval(
              hl.nd.array(np.arange(10).reshape(5, 2))
              @ hl.missing(hl.tndarray(hl.tint64, 2))
          )
          is None
      )
  
      assert np.array_equal(
          hl.eval(ones_int32 @ ones_float64),
          np_ones_int32 @ np_ones_float64,
      )
  
      with pytest.raises(ValueError):
          m @ 5
  
      with pytest.raises(ValueError):
          m @ hl.nd.array(5)
  
      with pytest.raises(ValueError):
          cube @ hl.nd.array(5)
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(r @ r)
      assert (
          "Matrix dimensions incompatible: (2, 3) can't be multiplied by matrix with dimensions (2, 3)"
          in str(exc.value)
      ), str(exc.value)
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(hl.nd.array([1, 2]) @ hl.nd.array([1, 2, 3]))
      assert "Matrix dimensions incompatible" in str(exc.value)
  
imports: import math
  import numpy
  import re
  from ..helpers import *
  import pytest
  from hail.utils.java import FatalError, HailUserError
label_desc: Use image node_id 15 for calling a global function with example usage: test_ndarray_matmul() without return types