code: def test_ndarray_reshape():
      np_single = np.array([8])
      single = hl.nd.array([8])
  
      np_zero_dim = np.array(4)
      zero_dim = hl.nd.array(4)
  
      np_a = np.array([1, 2, 3, 4, 5, 6])
      a = hl.nd.array(np_a)
  
      np_cube = np.array([0, 1, 2, 3, 4, 5, 6, 7]).reshape((2, 2, 2))
      cube = hl.nd.array([0, 1, 2, 3, 4, 5, 6, 7]).reshape((2, 2, 2))
      cube_to_rect = cube.reshape((2, 4))
      np_cube_to_rect = np_cube.reshape((2, 4))
      cube_t_to_rect = cube.transpose((1, 0, 2)).reshape((2, 4))
      np_cube_t_to_rect = np_cube.transpose((1, 0, 2)).reshape((2, 4))
  
      np_hypercube = np.arange(3 * 5 * 7 * 9).reshape((3, 5, 7, 9))
      hypercube = hl.nd.array(np_hypercube)
  
      np_shape_zero = np.array([])
      shape_zero = hl.nd.array(np_shape_zero)
  
      assert_ndarrays_eq(
          (single.reshape(()), np_single.reshape(())),
          (zero_dim.reshape(()), np_zero_dim.reshape(())),
          (zero_dim.reshape((1,)), np_zero_dim.reshape((1,))),
          (a.reshape((6,)), np_a.reshape((6,))),
          (a.reshape((2, 3)), np_a.reshape((2, 3))),
          (a.reshape(2, 3), np_a.reshape(2, 3)),
          (a.reshape((3, 2)), np_a.reshape((3, 2))),
          (a.reshape((3, -1)), np_a.reshape((3, -1))),
          (a.reshape((-1, 2)), np_a.reshape((-1, 2))),
          (cube_to_rect, np_cube_to_rect),
          (cube_t_to_rect, np_cube_t_to_rect),
          (
              hypercube.reshape((5, 7, 9, 3)).reshape((7, 9, 3, 5)),
              np_hypercube.reshape((7, 9, 3, 5)),
          ),
          (
              hypercube.reshape(hl.tuple([5, 7, 9, 3])),
              np_hypercube.reshape((5, 7, 9, 3)),
          ),
          (shape_zero.reshape((0, 5)), np_shape_zero.reshape((0, 5))),
          (shape_zero.reshape((-1, 5)), np_shape_zero.reshape((-1, 5))),
      )
  
      assert (
          hl.eval(hl.missing(hl.tndarray(hl.tfloat, 2)).reshape((4, 5)))
          is None
      )
      assert (
          hl.eval(
              hl.nd.array(hl.range(20)).reshape(
                  hl.missing(hl.ttuple(hl.tint64, hl.tint64))
              )
          )
          is None
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(hl.literal(np_cube).reshape((-1, -1)))
      assert "more than one -1" in str(exc.value)
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(hl.literal(np_cube).reshape((20,)))
      assert (
          "requested shape is incompatible with number of elements"
          in str(exc.value)
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(a.reshape((3,)))
      assert (
          "requested shape is incompatible with number of elements"
          in str(exc.value)
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(a.reshape(()))
      assert (
          "requested shape is incompatible with number of elements"
          in str(exc.value)
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(hl.literal(np_cube).reshape((0, 2, 2)))
      assert (
          "requested shape is incompatible with number of elements"
          in str(exc.value)
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(hl.literal(np_cube).reshape((2, 2, -2)))
      assert "must contain only nonnegative numbers or -1" in str(
          exc.value
      )
  
      with pytest.raises(HailUserError) as exc:
          hl.eval(shape_zero.reshape((0, -1)))
      assert "Can't reshape" in str(exc.value)
  
      with pytest.raises(TypeError):
          a.reshape(hl.tuple(["4", "5"]))
  
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 10 for calling a global function with example usage: test_ndarray_reshape() without return types