code: def do_levmarq(s, param_names, damping=0.1, decrease_damp_factor=10.,
          run_length=6, eig_update=True, collect_stats=False, rz_order=0,
          run_type=2, **kwargs):
      
      if rz_order > 0:
          aug = AugmentedState(s, param_names, rz_order=rz_order)
          lm = LMAugmentedState(aug, damping=damping, run_length=run_length,
                  decrease_damp_factor=decrease_damp_factor, eig_update=
                  eig_update, **kwargs)
      else:
          lm = LMGlobals(s, param_names, damping=damping, run_length=run_length,
                  decrease_damp_factor=decrease_damp_factor, eig_update=
                  eig_update, **kwargs)
      if run_type == 2:
          lm.do_run_2()
      elif run_type == 1:
          lm.do_run_1()
      else:
          raise ValueError('run_type=1,2 only')
      if collect_stats:
          return lm.get_termination_stats()
docs: Runs Levenberg-Marquardt optimization on a state.
  
      Convenience wrapper for LMGlobals. Same keyword args, but the defaults
      have been set to useful values for optimizing globals.
      See LMGlobals and LMEngine for documentation.
  
      See Also
      --------
          do_levmarq_particles : Levenberg-Marquardt optimization of a
              specified set of particles.
  
          do_levmarq_all_particle_groups : Levenberg-Marquardt optimization
              of all the particles in the state.
  
          LMGlobals : Optimizer object; the workhorse of do_levmarq.
  
          LMEngine : Engine superclass for all the optimizers.