docs: def build_ruptures(sources, src_filter, param, monitor):
      """
      :param sources: a list with a single UCERF source
      :param param: extra parameters
      :param monitor: a Monitor instance
      :returns: an AccumDict grp_id -> EBRuptures
      """
      [src] = sources
      res = AccumDict()
      res.calc_times = []
      sampl_mon = monitor('sampling ruptures', measuremem=True)
      res.trt = DEFAULT_TRT
      background_sids = src.get_background_sids(src_filter)
      sitecol = src_filter.sitecol
      samples = getattr(src, 'samples', 1)
      n_occ = AccumDict(accum=0)
      t0 = time.time()
      with sampl_mon:
          for sam_idx in range(samples):
              for ses_idx, ses_seed in param['ses_seeds']:
                  seed = sam_idx * TWO16 + ses_seed
                  rups, occs = generate_event_set(
                      src, background_sids, src_filter, ses_idx, seed)
                  for rup, occ in zip(rups, occs):
                      n_occ[rup] += occ
      tot_occ = sum(n_occ.values())
      dic = {'eff_ruptures': {src.src_group_id: src.num_ruptures}}
      eb_ruptures = [EBRupture(rup, src.id, src.src_group_id, n, samples)
                     for rup, n in n_occ.items()]
      dic['rup_array'] = stochastic.get_rup_array(eb_ruptures, src_filter)
      dt = time.time() - t0
      dic['calc_times'] = {src.id: numpy.array([tot_occ, len(sitecol), dt], F32)}
      return dic