<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nearest_interval(self, interval):
 """ This function returns the nearest interval to any given interval. """

        thresh_range = 25  # in cents
        if interval < self.intervals[0] - thresh_range or interval > self.intervals[-1] + thresh_range:
            raise IndexError("The interval given is beyond " + str(thresh_range)
                             + " cents over the range of intervals defined.")

        index = find_nearest_index(self.intervals, interval)
        return self.intervals[index]