code: def time_varying_coefficients(
      d,
      timelines,
      constant=False,
      independent=0,
      randgen=random.exponential,
  ):
      """
      Time vary coefficients
  
      d: the dimension of the dataset
      timelines: the observational times
      constant: True for constant coefficients
      independent: the number of coffients to set to 0 (covariate is ind of survival), or
        a list of covariates to make independent.
      randgen: how scalar coefficients (betas) are sampled.
  
      returns a matrix (t,d+1) of coefficients
      """
      t = timelines.shape[0]
      try:
          a = np.arange(d)
          random.shuffle(a)
          independent = a[:independent]
      except IndexError:
          pass
  
      n_funcs = len(FUNCS)
      coefficients = np.zeros((t, d))
      data_generators = []
      for i in range(d):
          f = (
              FUNCS[random.randint(0, n_funcs)]
              if not constant
              else constant_
          )
          if i in independent:
              beta = 0
          else:
              beta = randgen((1 - constant) * 0.5 / d)
          coefficients[:, i] = f(
              timelines, alpha=randgen(2000.0 / t), beta=beta
          )
          data_generators.append(f.__doc__)
  
      df_coefficients = pd.DataFrame(
          coefficients, columns=data_generators, index=timelines
      )
      return df_coefficients
  
imports: import numpy
  import pandas
  from scipy import stats
  from scipy.optimize import newton
  from scipy.integrate import cumtrapz
label_desc: Use image node_id 11 for calling a global function with example usage: time_varying_coefficients(d, timelines, constant, independent, randgen) and returns: df_coefficients