<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_perplexity(self, new_perplexity):
 """Change the perplexity of the affinity matrix. Note that we only allow lowering the perplexity or restoring it to its original value. This restriction exists because setting a higher perplexity value requires recomputing all the nearest neighbors, which can take a long time. To avoid potential confusion as to why execution time is slow, this is not allowed. If you would like to increase the perplexity above the initial value, simply create a new instance. Parameters new_perplexity: float The new perplexity. """

        # If the value hasn't changed, there's nothing to do
        if new_perplexity == self.perplexity:
            return
        # Verify that the perplexity isn't too large
        new_perplexity = self.check_perplexity(new_perplexity)
        # Recompute the affinity matrix
        k_neighbors = min(self.n_samples - 1, int(3 * new_perplexity))
        if k_neighbors > self.__neighbors.shape[1]:
            raise RuntimeError(
                "The desired perplexity `%.2f` is larger than the initial one "
                "used. This would need to recompute the nearest neighbors, "
                "which is not efficient. Please create a new `%s` instance "
                "with the increased perplexity."
                % (new_perplexity, self.__class__.__name__)
            )

        self.perplexity = new_perplexity
        self.P = joint_probabilities_nn(
            self.__neighbors[:, :k_neighbors],
            self.__distances[:, :k_neighbors],
            [self.perplexity],
            symmetrize=True,
            n_jobs=self.n_jobs,
        )