<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def compute_rewards(self, scores):
 """Retain the K best scores, and replace the rest with nans"""

        if len(scores) > self.k:
            scores = np.copy(scores)
            inds = np.argsort(scores)[:-self.k]
            scores[inds] = np.nan

        return list(scores)