code: def ipc_weights(event, time):
      
      if event.all():
          return numpy.ones(time.shape[0])
  
      unique_time, p = kaplan_meier_estimator(~event, time)
  
      idx = numpy.searchsorted(unique_time, time[event])
      Ghat = p[idx]
  
      assert (Ghat > 0).all()
  
      weights = numpy.zeros(time.shape[0])
      weights[event] = 1.0 / Ghat
  
      return weights
docs: Compute inverse probability of censoring weights
  
      Parameters
      ----------
      event : array, shape = (n_samples,)
          Boolean event indicator.
  
      time : array, shape = (n_samples,)
          Time when a subject experienced an event or was censored.
  
      Returns
      -------
      weights : array, shape = (n_samples,)
          inverse probability of censoring weights