<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_weighted_poes(gsim, sctx, rctx, dctx, imt, imls, truncation_level, weighting=DEFAULT_WEIGHTING):
 """ This function implements the NGA West 2 GMPE epistemic uncertainty adjustment factor without re-calculating the actual GMPE each time. :param gsim: Instance of the GMPE :param list weighting: Weightings as a list of tuples of (weight, number standard deviations of the epistemic uncertainty adjustment) """

    if truncation_level is not None and truncation_level < 0:
        raise ValueError('truncation level must be zero, positive number '
                         'or None')
    gsim._check_imt(imt)
    adjustment = nga_west2_epistemic_adjustment(rctx.mag, dctx.rrup)
    adjustment = adjustment.reshape(adjustment.shape + (1, ))
    if truncation_level == 0:
        # zero truncation mode, just compare imls to mean
        imls = gsim.to_distribution_values(imls)
        mean, _ = gsim.get_mean_and_stddevs(sctx, rctx, dctx, imt, [])
        mean = mean.reshape(mean.shape + (1, ))
        output = np.zeros([mean.shape[0], imls.shape[0]])
        for (wgt, fct) in weighting:
            output += (wgt *
                       (imls <= (mean + (fct * adjustment))).astype(float))
        return output
    else:
        # use real normal distribution
        assert (const.StdDev.TOTAL
                in gsim.DEFINED_FOR_STANDARD_DEVIATION_TYPES)
        imls = gsim.to_distribution_values(imls)
        mean, [stddev] = gsim.get_mean_and_stddevs(sctx, rctx, dctx, imt,
                                                   [const.StdDev.TOTAL])
        mean = mean.reshape(mean.shape + (1, ))
        stddev = stddev.reshape(stddev.shape + (1, ))
        output = np.zeros([mean.shape[0], imls.shape[0]])
        for (wgt, fct) in weighting:
            values = (imls - (mean + (fct * adjustment))) / stddev
            if truncation_level is None:
                output += (wgt * _norm_sf(values))
            else:
                output += (wgt * _truncnorm_sf(truncation_level, values))
        return output