code: def test_leastsq_failing():
      """
      Test for cases where leastsq fitting fails and the results from a linear
      fit is returned.
      """
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always", category=UserWarning)
          fit_single = ivim_model_trr.fit(noisy_single)
          assert_greater_equal(len(w), 3)
          u_warn = [
              l_w for l_w in w if issubclass(l_w.category, UserWarning)
          ]
          assert_greater_equal(len(u_warn), 3)
          message = [
              "x0 obtained from linear fitting is not feasible",
              "x0 is unfeasible",
              "Bounds are violated for leastsq fitting",
          ]
          assert_greater_equal(
              len(
                  [
                      lw
                      for lw in u_warn
                      for m in message
                      if m in str(lw.message)
                  ]
              ),
              3,
          )
  
      # Test for the S0 and D values
      assert_array_almost_equal(
          fit_single.S0_predicted, 4356.268901117833
      )
      assert_array_almost_equal(fit_single.D, 6.936684e-04)
  
imports: import warnings
  import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_array_less, assert_, assert_equal
  from dipy.testing import assert_greater_equal
  import pytest
  from dipy.reconst.ivim import ivim_prediction, IvimModel
  from dipy.core.gradients import gradient_table, generate_bvecs
  from dipy.sims.voxel import multi_tensor
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 23 for calling a global function with example usage: test_leastsq_failing() without return types