code: def build_loss_tables(dstore):
      
      oq = dstore['oqparam']
      L = len(oq.loss_dt().names)
      R = dstore['csm_info'].get_num_rlzs()
      serials = dstore['ruptures']['serial']
      idx_by_ser = dict(zip(serials, range(len(serials))))
      tbl = numpy.zeros((len(serials), L), F32)
      lbr = numpy.zeros((R, L), F32)  # losses by rlz
      for rec in dstore['losses_by_event'].value:  # call .value for speed
          idx = idx_by_ser[rec['eid'] // TWO32]
          tbl[idx] += rec['loss']
          lbr[rec['rlzi']] += rec['loss']
      return tbl, lbr
docs: Compute the total losses by rupture and losses by rlzi.