Impute a single feature from the others provided.

        This function predicts the missing values of one of the features using
        the current estimates of all the other features. The ``predictor`` must
        support ``return_std=True`` in its ``predict`` method for this function
        to work.

        Parameters
        ----------
        X_filled : ndarray
            Input data with the most recent imputations.

        mask_missing_values : ndarray
            Input data's missing indicator matrix.

        feat_idx : int
            Index of the feature currently being imputed.

        neighbor_feat_idx : ndarray
            Indices of the features to be used in imputing ``feat_idx``.

        predictor : object
            The predictor to use at this step of the round-robin imputation.
            If ``sample_posterior`` is True, the predictor must support
            ``return_std`` in its ``predict`` method.
            If None, it will be cloned from self._predictor.

        fit_mode : boolean, default=True
            Whether to fit and predict with the predictor or just predict.

        Returns
        -------
        X_filled : ndarray
            Input data with ``X_filled[missing_row_mask, feat_idx]`` updated.

        predictor : predictor with sklearn API
            The fitted predictor used to impute
            ``X_filled[missing_row_mask, feat_idx]``.

def _impute_one_feature(self,
                            X_filled,
                            mask_missing_values,
                            feat_idx,
                            neighbor_feat_idx,
                            predictor=None,
                            fit_mode=True):
        """Impute a single feature from the others provided.

        This function predicts the missing values of one of the features using
        the current estimates of all the other features. The ``predictor`` must
        support ``return_std=True`` in its ``predict`` method for this function
        to work.

        Parameters
        ----------
        X_filled : ndarray
            Input data with the most recent imputations.

        mask_missing_values : ndarray
            Input data's missing indicator matrix.

        feat_idx : int
            Index of the feature currently being imputed.

        neighbor_feat_idx : ndarray
            Indices of the features to be used in imputing ``feat_idx``.

        predictor : object
            The predictor to use at this step of the round-robin imputation.
            If ``sample_posterior`` is True, the predictor must support
            ``return_std`` in its ``predict`` method.
            If None, it will be cloned from self._predictor.

        fit_mode : boolean, default=True
            Whether to fit and predict with the predictor or just predict.

        Returns
        -------
        X_filled : ndarray
            Input data with ``X_filled[missing_row_mask, feat_idx]`` updated.

        predictor : predictor with sklearn API
            The fitted predictor used to impute
            ``X_filled[missing_row_mask, feat_idx]``.
        """

        # if nothing is missing, just return the default
        # (should not happen at fit time because feat_ids would be excluded)
        missing_row_mask = mask_missing_values[:, feat_idx]
        if not np.any(missing_row_mask):
            return X_filled, predictor

        if predictor is None and fit_mode is False:
            raise ValueError("If fit_mode is False, then an already-fitted "
                             "predictor should be passed in.")

        if predictor is None:
            predictor = clone(self._predictor)

        if fit_mode:
            X_train = safe_indexing(X_filled[:, neighbor_feat_idx],
                                    ~missing_row_mask)
            y_train = safe_indexing(X_filled[:, feat_idx],
                                    ~missing_row_mask)
            predictor.fit(X_train, y_train)

        # get posterior samples
        X_test = safe_indexing(X_filled[:, neighbor_feat_idx],
                               missing_row_mask)
        if self.sample_posterior:
            mus, sigmas = predictor.predict(X_test, return_std=True)
            good_sigmas = sigmas > 0
            imputed_values = np.zeros(mus.shape, dtype=X_filled.dtype)
            imputed_values[~good_sigmas] = mus[~good_sigmas]
            imputed_values[good_sigmas] = self.random_state_.normal(
                loc=mus[good_sigmas], scale=sigmas[good_sigmas])
        else:
            imputed_values = predictor.predict(X_test)

        # clip the values
        imputed_values = self.clip(imputed_values)

        # update the feature
        X_filled[missing_row_mask, feat_idx] = imputed_values
        return X_filled, predictor