def raw_reward_threshold(threshold):
    """Return a reward processor that cut off at a threshold."""
    def fn(metadata):
        if metadata['raw_reward'] > threshold:
            return 1.
        elif metadata['raw_reward'] > 0:
            return -1
        return metadata['raw_reward']
    return fn