code: def _fit(
          self,
          minimizing_function_args,
          iterative_fitting,
          initial_params,
          params_size,
          disp,
          tol=1e-6,
          fit_method="Nelder-Mead",
          maxiter=2000,
          **kwargs
      ):
          
          ll = []
          sols = []
  
          if iterative_fitting <= 0:
              raise ValueError("iterative_fitting parameter should be greater than 0 as of lifetimes v0.2.1")
  
          if iterative_fitting > 1 and initial_params is not None:
              raise ValueError(
                  "iterative_fitting and initial_params should not be both set, as no improvement could be made."
              )
  
          # set options for minimize, if specified in kwargs will be overwritten
          minimize_options = {}
          minimize_options["disp"] = disp
          minimize_options["maxiter"] = maxiter
          minimize_options.update(kwargs)
  
          total_count = 0
          while total_count < iterative_fitting:
              current_init_params = (
                  np.random.normal(1.0, scale=0.05, size=params_size) if initial_params is None else initial_params
              )
              if minimize_options["disp"]:
                  print("Optimize function with {}".format(fit_method))
  
              output = minimize(
                  self._negative_log_likelihood,
                  method=fit_method,
                  tol=tol,
                  x0=current_init_params,
                  args=minimizing_function_args,
                  options=minimize_options,
              )
              sols.append(output.x)
              ll.append(output.fun)
  
              total_count += 1
          argmin_ll, min_ll = min(enumerate(ll), key=lambda x: x[1])
          minimizing_params = sols[argmin_ll]
          return minimizing_params, min_ll
docs: Fit function for fitters.