code: def test_forward(plot=False):
      np.random.seed(1)
      for j in range(40):
          if j % 2 == 0:
              wrapped_dims = np.array([False, False])
          else:
              wrapped_dims = None
          start = np.random.uniform(size=2)
          direction = np.random.normal(size=2)
          direction /= (direction**2).sum() ** 0.5
          points = []
          for i in range(100):
              newpoint, _ = linear_steps_with_reflection(
                  start, direction, i * 0.04, wrapped_dims=wrapped_dims
              )
              points.append(newpoint)
          points = np.array(points)
  
          a, b = linear_steps_with_reflection(
              start, direction, 1 * 0.04, wrapped_dims=wrapped_dims
          )
          c, d = linear_steps_with_reflection(
              a, b, 1 * 0.04, wrapped_dims=wrapped_dims
          )
          e, f = linear_steps_with_reflection(
              start, direction, 2 * 0.04, wrapped_dims=wrapped_dims
          )
          assert_allclose(c, e)
          assert_allclose(d, f)
  
          np.testing.assert_allclose(points[0], start)
          if plot:
              plt.plot(start[0], start[1], "o ")
              plt.plot(points[:, 0], points[:, 1], "x-")
              plt.xlim(0, 1)
              plt.ylim(0, 1)
              plt.savefig(
                  "flatnuts_test_forward_%02d.png" % j,
                  bbox_inches="tight",
              )
              plt.close()
          assert np.isfinite(points).all(), (j, points)
          assert (points > 0).all(), (j, points)
          assert (points < 1).all(), (j, points)
          delta = ((points[1:, :] - points[:-1, :]) ** 2).sum(
              axis=1
          ) ** 0.5
          # print(delta.max(), delta.min(), direction)
          assert (delta <= 0.04001).all(), (
              j,
              delta,
              np.where(delta > 0.1),
              points,
          )
  
file_path: ultranest/tests/test_samplingpath.py
imports: import numpy
  import matplotlib.pyplot
  from ultranest.mlfriends import AffineLayer, MLFriends
  from ultranest.samplingpath import SamplingPath, ContourSamplingPath
  from ultranest.samplingpath import box_line_intersection, nearest_box_intersection_line, linear_steps_with_reflection, angle, get_sphere_tangents, norm
  from numpy.testing import assert_allclose
label_desc: Use image node_id 5 for calling a global function with example usage: test_forward(plot) without return types