code: def scipy_minimize_fit(
      turnbull_interval_lookup,
      turnbull_intervals,
      weights,
      tol,
      verbose,
  ):
      import autograd.numpy as anp
      from autograd import value_and_grad
      from scipy.optimize import minimize
  
      def cumulative_sum(p):
          return anp.concatenate((anp.zeros(1), p)).cumsum()
  
      def negative_log_likelihood(p, turnbull_interval_lookup, weights):
          P = cumulative_sum(p)
          ix = anp.array(list(turnbull_interval_lookup.values()))
          return -(
              weights * anp.log(P[ix[:, 1] + 1] - P[ix[:, 0]])
          ).sum()
  
      def con(p):
          return p.sum() - 1
  
      # initialize to equal weight
      T = len(turnbull_intervals)
      p = 1 / T * np.ones(T)
  
      cons = {"type": "eq", "fun": con}
      results = minimize(
          value_and_grad(negative_log_likelihood),
          args=(turnbull_interval_lookup, weights),
          x0=p,
          bounds=[(0, 1)] * T,
          jac=True,
          constraints=cons,
          tol=tol,
          options={"disp": verbose},
      )
      return results.x
  
imports: from collections import defaultdict, namedtuple
  import warnings
  import numpy
  from numpy.linalg import norm
  import pandas
  from lifelines.exceptions import ConvergenceWarning
  from typing import *
label_desc: Use image node_id 12 for calling a global function with example usage: scipy_minimize_fit(turnbull_interval_lookup, turnbull_intervals, weights, tol, verbose) and returns: results, anp, unknown, unknown