code: def find_events(self, testing_data, var=None, scramble=False):
          
  
          if var is None:
              if not hasattr(self, 'event_var_'):
                  raise NotFittedError(("Event variance must be provided, if "
                                        "not previously set by fit()"))
              else:
                  var = self.event_var_
  
          if not hasattr(self, 'event_pat_'):
              raise NotFittedError(("The event patterns must first be set "
                                    "by fit() or set_event_patterns()"))
          if scramble:
              mean_pat = self.event_pat_[:, np.random.permutation(self.n_events)]
          else:
              mean_pat = self.event_pat_
  
          logprob = self._logprob_obs(testing_data.T, mean_pat, var)
          lg, test_ll = self._forward_backward(logprob)
          segments = np.exp(lg)
  
          return segments, test_ll
docs: Applies learned event segmentation to new testing dataset
  
          After fitting an event segmentation using fit() or setting event
          patterns directly using set_event_patterns(), this function finds the
          same sequence of event patterns in a new testing dataset.
  
          Parameters
          ----------
          testing_data: timepoint by voxel ndarray
              fMRI data to segment based on previously-learned event patterns
  
          var: float or 1D ndarray of length equal to the number of events
              default: uses variance that maximized training log-likelihood
              Variance of the event Gaussians. If scalar, all events are
              assumed to have the same variance. If fit() has not previously
              been run, this must be specifed (cannot be None).
  
          scramble: bool : default False
              If true, the order of the learned events are shuffled before
              fitting, to give a null distribution
  
          Returns
          -------
          segments : time by event ndarray
              The resulting soft segmentation. segments[t,e] = probability
              that timepoint t is in event e
  
          test_ll : float
              Log-likelihood of model fit