code: def test_crop_bracket(plot=False):
      ucurrent = np.array([0.39676747, 0.53881673])
      v = np.array([-0.79619985, -0.60503372])
      ellipsoid_center = np.array([0.23556461, 0.49899689])
      ellipsoid_inv_axes = np.array(
          [[-3.28755896, 0.70136518], [1.33333377, 1.72933397]]
      )
      enlarge = 26.66439694551674
      ellipsoid_invcov = np.array(
          [[11.29995701, -3.17051875], [-3.17051875, 4.76837493]]
      )
      # enlarge = 1.0
      # ellipsoid_inv_axes = np.array([[1.0, 0.], [0., 1]])
  
      eleft, eright = ellipsoid_bracket(
          ucurrent, v, ellipsoid_center, ellipsoid_inv_axes, enlarge
      )
      if plot:
          us = np.random.uniform(-2, +2, size=(10000, 2))
          d = us - ellipsoid_center
          r = np.einsum("ij,jk,ik->i", d, ellipsoid_invcov, d)
          mask_inside = r <= enlarge
  
          import matplotlib.pyplot as plt
  
          plt.plot(us[mask_inside, 0], us[mask_inside, 1], "+", ms=2)
          plt.plot(ucurrent[0], ucurrent[1], "o ", ms=2)
          plt.plot(
              [ucurrent[0] + eleft * v[0], ucurrent[0] + eright * v[0]],
              [ucurrent[1] + eleft * v[1], ucurrent[1] + eright * v[1]],
              "-s",
              ms=8,
          )
          plt.savefig("test_crop_bracket.pdf", bbox_inches="tight")
      print("left:", eleft, ucurrent + v * eleft)
      assert eleft <= 0, eleft
      assert_point_touches_ellipsoid(
          ucurrent,
          v,
          eleft,
          ellipsoid_center,
          ellipsoid_invcov,
          enlarge,
      )
      print("right:", eright, ucurrent + v * eright)
      assert eright >= 0, eright
      assert_point_touches_ellipsoid(
          ucurrent,
          v,
          eright,
          ellipsoid_center,
          ellipsoid_invcov,
          enlarge,
      )
  
      left, right, cropleft, cropright = crop_bracket_at_unit_cube(
          ucurrent, v, eleft, eright
      )
      if plot:
          plt.plot(
              [ucurrent[0] + left * v[0], ucurrent[0] + right * v[0]],
              [ucurrent[1] + left * v[1], ucurrent[1] + right * v[1]],
              "s--",
              ms=8,
          )
          plt.savefig("test_crop_bracket.pdf", bbox_inches="tight")
          plt.close()
      assert cropleft
      assert cropright
      assert (ucurrent + v * left <= 1).all(), (
          ucurrent,
          v,
          ellipsoid_center,
          ellipsoid_inv_axes,
          enlarge,
      )
      assert (ucurrent + v * right <= 1).all(), (
          ucurrent,
          v,
          ellipsoid_center,
          ellipsoid_inv_axes,
          enlarge,
      )
      assert (ucurrent + v * left >= 0).all(), (
          ucurrent,
          v,
          ellipsoid_center,
          ellipsoid_inv_axes,
          enlarge,
      )
      assert (ucurrent + v * right >= 0).all(), (
          ucurrent,
          v,
          ellipsoid_center,
          ellipsoid_inv_axes,
          enlarge,
      )
  
imports: import numpy
  from ultranest.mlfriends import ScalingLayer, AffineLayer, MLFriends
  from ultranest import ReactiveNestedSampler
  from ultranest.stepsampler import RegionMHSampler, CubeMHSampler, CubeSliceSampler, RegionSliceSampler, SpeedVariableRegionSliceSampler, RegionBallSliceSampler
  from ultranest.stepsampler import generate_region_random_direction, ellipsoid_bracket, crop_bracket_at_unit_cube
  from ultranest.pathsampler import SamplingPathStepSampler
  from ultranest.stepsampler import select_random_livepoint, IslandPopulationRandomLivepointSelector
  from numpy.testing import assert_allclose
label_desc: Use image node_id 16 for calling a global function with example usage: test_crop_bracket(plot) without return types