<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def minute_index_to_session_labels(self, index):
 """ Given a sorted DatetimeIndex of market minutes, return a DatetimeIndex of the corresponding session labels. Parameters index: pd.DatetimeIndex or pd.Series The ordered list of market minutes we want session labels for. Returns ------- pd.DatetimeIndex (UTC) The list of session labels corresponding to the given minutes. """

        if not index.is_monotonic_increasing:
            raise ValueError(
                "Non-ordered index passed to minute_index_to_session_labels."
            )

        # Find the indices of the previous open and the next close for each
        # minute.
        prev_opens = (
            self._opens.values.searchsorted(index.values, side='right') - 1
        )
        next_closes = (
            self._closes.values.searchsorted(index.values, side='left')
        )

        # If they don't match, the minute is outside the trading day. Barf.
        mismatches = (prev_opens != next_closes)
        if mismatches.any():
            # Show the first bad minute in the error message.
            bad_ix = np.flatnonzero(mismatches)[0]
            example = index[bad_ix]

            prev_day = prev_opens[bad_ix]
            prev_open, prev_close = self.schedule.iloc[prev_day]
            next_open, next_close = self.schedule.iloc[prev_day + 1]

            raise ValueError(
                "{num} non-market minutes in minute_index_to_session_labels:\n"
                "First Bad Minute: {first_bad}\n"
                "Previous Session: {prev_open} -> {prev_close}\n"
                "Next Session: {next_open} -> {next_close}"
                .format(
                    num=mismatches.sum(),
                    first_bad=example,
                    prev_open=prev_open, prev_close=prev_close,
                    next_open=next_open, next_close=next_close)
            )

        return self.schedule.index[prev_opens]