class_docstr: Ivim model
      
docstr: Fit method of the IvimModelTRR class.
  
  The fitting takes place in the following steps: Linear fitting for D
  (bvals > `split_b_D` (default: 400)) and store S0_prime. Another linear
  fit for S0 (bvals < split_b_S0 (default: 200)). Estimate f using
  1 - S0_prime/S0. Use non-linear least squares to fit D_star and f.
  
  We do a final non-linear fitting of all four parameters and select the
  set of parameters which make sense physically. The criteria for
  selecting a particular set of parameters is checking the
  pseudo-perfusion fraction. If the fraction is more than `f_threshold`
  (default: 25%), we will reject the solution obtained from non-linear
  least squares fitting and consider only the linear fit.
  
  
  Parameters
  ----------
  data : array
      The measured signal from one voxel. A multi voxel decorator
      will be applied to this fit method to scale it and apply it
      to multiple voxels.
  
  
  Returns
  -------
  IvimFit object
code: def fit(self, data):
      """Fit method of the IvimModelTRR class.
  
      The fitting takes place in the following steps: Linear fitting for D
      (bvals > `split_b_D` (default: 400)) and store S0_prime. Another linear
      fit for S0 (bvals < split_b_S0 (default: 200)). Estimate f using
      1 - S0_prime/S0. Use non-linear least squares to fit D_star and f.
  
      We do a final non-linear fitting of all four parameters and select the
      set of parameters which make sense physically. The criteria for
      selecting a particular set of parameters is checking the
      pseudo-perfusion fraction. If the fraction is more than `f_threshold`
      (default: 25%), we will reject the solution obtained from non-linear
      least squares fitting and consider only the linear fit.
  
  
      Parameters
      ----------
      data : array
          The measured signal from one voxel. A multi voxel decorator
          will be applied to this fit method to scale it and apply it
          to multiple voxels.
  
  
      Returns
      -------
      IvimFit object
      """
      # Get S0_prime and D - parameters assuming a single exponential decay
      # for signals for bvals greater than `split_b_D`
      S0_prime, D = self.estimate_linear_fit(
          data, self.split_b_D, less_than=False
      )
  
      # Get S0 and D_star_prime - parameters assuming a single exponential
      # decay for for signals for bvals greater than `split_b_S0`.
  
      S0, D_star_prime = self.estimate_linear_fit(
          data, self.split_b_S0, less_than=True
      )
      # Estimate f
      f_guess = 1 - S0_prime / S0
  
      # Fit f and D_star using leastsq.
      params_f_D_star = [f_guess, D_star_prime]
      f, D_star = self.estimate_f_D_star(params_f_D_star, data, S0, D)
      params_linear = np.array([S0, f, D_star, D])
      # Fit parameters again if two_stage flag is set.
      if self.two_stage:
          params_two_stage = self._leastsq(data, params_linear)
          bounds_violated = ~(
              np.all(params_two_stage >= self.bounds[0])
              and (np.all(params_two_stage <= self.bounds[1]))
          )
          if bounds_violated:
              warningMsg = "Bounds are violated for leastsq fitting. "
              warningMsg += "Returning parameters from linear fit"
              warnings.warn(warningMsg, UserWarning)
              return IvimFit(self, params_linear)
          else:
              return IvimFit(self, params_two_stage)
      else:
          return IvimFit(self, params_linear)
  
imports: import warnings
  import numpy
  from scipy.optimize import least_squares, differential_evolution
  from dipy.reconst.base import ReconstModel
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 2 for calling the IvimModelTRR obj's underlying member method code with example usage: obj.fit(data) and returns: IvimFit, IvimFit, IvimFit