code: def make_figure(losses_by_rlzi, loss_types, nbins):
      
      # NB: matplotlib is imported inside since it is a costly import
      import matplotlib.pyplot as plt
      R = len(losses_by_rlzi)
      L = len(loss_types)
      fig = plt.figure()
      for rlz in losses_by_rlzi:
          rlzi = int(rlz[4:])  # strip rlz-
          losses = losses_by_rlzi[rlz]['loss'].reshape(-1, L)
          print('%s, num_events=%d' % (rlz, len(losses)))
          for lti, lt in enumerate(loss_types):
              ls = losses[:, lti]
              if numpy.isnan(ls).all():
                  continue
              ax = fig.add_subplot(R, L, rlzi * L + lti + 1)
              ax.set_xlabel('%s, loss_type=%s' % (rlz, lt))
              ax.hist(ls, nbins, rwidth=.9)
              ax.set_title('loss=%.5e$\pm$%.5e' % (ls.mean(), ls.std(ddof=1)))
      return plt
docs: :param losses_by_event: composite array (eid, rlzi, losses)
      :param loss_types: list of loss types