docs: def ebrisk(rupgetter, srcfilter, param, monitor):
      """
      :param rupgetter:
          a RuptureGetter instance
      :param srcfilter:
          a SourceFilter instance
      :param param:
          a dictionary of parameters
      :param monitor:
          :class:`openquake.baselib.performance.Monitor` instance
      :returns:
          an ArrayWrapper with shape (E, L, T, ...)
      """
      riskmodel = param['riskmodel']
      E = rupgetter.num_events
      L = len(riskmodel.lti)
      N = len(srcfilter.sitecol.complete)
      e1 = rupgetter.first_event
      with monitor('getting assets', measuremem=False):
          with datastore.read(srcfilter.filename) as dstore:
              assetcol = dstore['assetcol']
          assets_by_site = assetcol.assets_by_site()
      A = len(assetcol)
      getter = getters.GmfGetter(rupgetter, srcfilter, param['oqparam'])
      with monitor('getting hazard'):
          getter.init()  # instantiate the computers
          hazard = getter.get_hazard()  # sid -> (rlzi, sid, eid, gmv)
      mon_risk = monitor('computing risk', measuremem=False)
      mon_agg = monitor('aggregating losses', measuremem=False)
      events = rupgetter.get_eid_rlz()
      # numpy.testing.assert_equal(events['eid'], sorted(events['eid']))
      eid2idx = dict(zip(events['eid'], range(e1, e1 + E)))
      tagnames = param['aggregate_by']
      shape = assetcol.tagcol.agg_shape((E, L), tagnames)
      elt_dt = [('eid', U64), ('rlzi', U16), ('loss', (F32, shape[1:]))]
      if param['asset_loss_table']:
          alt = numpy.zeros((A, E, L), F32)
      acc = numpy.zeros(shape, F32)  # shape (E, L, T...)
      if param['avg_losses']:
          losses_by_A = numpy.zeros((A, L), F32)
      else:
          losses_by_A = 0
      # NB: IMT-dependent weights are not supported in ebrisk
      times = numpy.zeros(N)  # risk time per site_id
      num_events_per_sid = 0
      epspath = param['epspath']
      for sid, haz in hazard.items():
          t0 = time.time()
          assets_on_sid = assets_by_site[sid]
          if len(assets_on_sid) == 0:
              continue
          num_events_per_sid += len(haz)
          weights = getter.weights[haz['rlzi'], 0]
          assets_by_taxo = get_assets_by_taxo(assets_on_sid, epspath)
          eidx = numpy.array([eid2idx[eid] for eid in haz['eid']]) - e1
          haz['eid'] = eidx + e1
          with mon_risk:
              out = riskmodel.get_output(assets_by_taxo, haz)
          with mon_agg:
              for a, asset in enumerate(assets_on_sid):
                  aid = asset['ordinal']
                  tagi = asset[tagnames] if tagnames else ()
                  tagidxs = tuple(idx - 1 for idx in tagi)
                  for lti, lt in enumerate(riskmodel.loss_types):
                      lratios = out[lt][a]
                      if lt == 'occupants':
                          losses = lratios * asset['occupants_None']
                      else:
                          losses = lratios * asset['value-' + lt]
                      if param['asset_loss_table']:
                          alt[aid, eidx, lti] = losses
                      acc[(eidx, lti) + tagidxs] += losses
                      if param['avg_losses']:
                          losses_by_A[aid, lti] += losses @ weights
              times[sid] = time.time() - t0
      if hazard:
          num_events_per_sid /= len(hazard)
      with monitor('building event loss table'):
          elt = numpy.fromiter(
              ((event['eid'], event['rlz'], losses)
               for event, losses in zip(events, acc) if losses.sum()), elt_dt)
          agg = general.AccumDict(accum=numpy.zeros(shape[1:], F32))  # rlz->agg
          for rec in elt:
              agg[rec['rlzi']] += rec['loss'] * param['ses_ratio']
      res = {'elt': elt, 'agg_losses': agg, 'times': times,
             'events_per_sid': num_events_per_sid}
      if param['avg_losses']:
          res['losses_by_A'] = losses_by_A * param['ses_ratio']
      if param['asset_loss_table']:
          res['alt_eids'] = alt, events['eid']
      return res