code: def test_stepsampler_adapt_when_stuck(plot=False):
      # check that a stuck sampler can free itself
      np.random.seed(7)
      us = np.random.normal(0.7, 0.0001, size=(1000, len(paramnames)))
      region = make_region(len(paramnames), us=us)
      Ls = loglike_vectorized(us)
      Lmin = Ls.min()
  
      print("CubeMHSampler")
      stepsampler = CubeMHSampler(nsteps=1, region_filter=True)
      np.random.seed(23)
      old_scale = stepsampler.scale
      for i in range(1000):
          if i > 100:
              assert False, i
          unew, pnew, Lnew, nc = stepsampler.__next__(
              region, Lmin, us, Ls, transform, loglike, ndraw=10
          )
          if unew is not None:
              break
  
      new_scale = stepsampler.scale
      assert new_scale != old_scale
      assert new_scale < 0.01, (new_scale, unew)
  
      print("CubeSliceSampler")
      stepsampler = CubeSliceSampler(nsteps=1, region_filter=True)
      np.random.seed(23)
      old_scale = stepsampler.scale
      for j in range(100):
          for i in range(1000):
              if i > 100:
                  assert False, i
              unew, pnew, Lnew, nc = stepsampler.__next__(
                  region, Lmin, us, Ls, transform, loglike, ndraw=10
              )
              if unew is not None:
                  break
  
      new_scale = stepsampler.scale
      assert new_scale != old_scale
      assert new_scale < 0.01, (new_scale, unew)
  
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 12 for calling a global function with example usage: test_stepsampler_adapt_when_stuck(plot) without return types