code: def test_ellipsoid_bracket(plot=False):
      for seed in range(20):
          print("seed:", seed)
          np.random.seed(seed)
          if seed % 2 == 0:
              us = np.random.normal(
                  size=(2 ** np.random.randint(3, 10), 2)
              )
              us /= ((us**2).sum(axis=1) ** 0.5).reshape((-1, 1))
              us = us * 0.1 + 0.5
          else:
              us = np.random.uniform(
                  size=(2 ** np.random.randint(3, 10), 2)
              )
  
          if plot:
              import matplotlib.pyplot as plt
  
              plt.plot(us[:, 0], us[:, 1], "o ", ms=2)
  
          transformLayer = ScalingLayer()
          region = MLFriends(us, transformLayer)
          try:
              (
                  region.maxradiussq,
                  region.enlarge,
              ) = region.compute_enlargement()
              region.create_ellipsoid()
          except ValueError:
              continue
  
          print(region.ellipsoid_center)
          print(region.enlarge)
          print(region.ellipsoid_cov)
          print(region.ellipsoid_invcov)
          print(region.ellipsoid_axes)
          print(region.ellipsoid_inv_axes)
  
          ucurrent = np.array(
              [2**0.5 * 0.1 / 2 + 0.5, 2**0.5 * 0.1 / 2 + 0.5]
          )
          ucurrent = np.array([0.4, 0.525])
          v = np.array([1.0, 0])
          if plot:
              plt.plot(ucurrent[0], ucurrent[1], "o")
          print("from", ucurrent, "in direction", v)
          left, right = ellipsoid_bracket(
              ucurrent,
              v,
              region.ellipsoid_center,
              region.ellipsoid_inv_axes,
              region.enlarge,
          )
          uleft = ucurrent + v * left
          uright = ucurrent + v * right
  
          if plot:
              plt.plot(
                  [uleft[0], uright[0]], [uleft[1], uright[1]], "x-"
              )
  
              plt.savefig(
                  "test_ellipsoid_bracket.pdf", bbox_inches="tight"
              )
              plt.close()
          print("ellipsoid bracket:", left, right)
          assert left <= 0, left
          assert right >= 0, right
  
          assert_point_touches_ellipsoid(
              ucurrent,
              v,
              left,
              region.ellipsoid_center,
              region.ellipsoid_invcov,
              region.enlarge,
          )
          assert_point_touches_ellipsoid(
              ucurrent,
              v,
              right,
              region.ellipsoid_center,
              region.ellipsoid_invcov,
              region.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 15 for calling a global function with example usage: test_ellipsoid_bracket(plot) without return types