code: def sample(self, n_samples=1, random_state=None):
          
          check_is_fitted(self, "startprob_")
          self._check()
  
          if random_state is None:
              random_state = self.random_state
          random_state = check_random_state(random_state)
  
          startprob_cdf = np.cumsum(self.startprob_)
          transmat_cdf = np.cumsum(self.transmat_, axis=1)
  
          currstate = (startprob_cdf > random_state.rand()).argmax()
          state_sequence = [currstate]
          X = [self._generate_sample_from_state(
              currstate, random_state=random_state)]
  
          for t in range(n_samples - 1):
              currstate = (transmat_cdf[currstate] > random_state.rand()) \
                  .argmax()
              state_sequence.append(currstate)
              X.append(self._generate_sample_from_state(
                  currstate, random_state=random_state))
  
          return np.atleast_2d(X), np.array(state_sequence, dtype=int)
docs: Generate random samples from the model.
  
          Parameters
          ----------
          n_samples : int
              Number of samples to generate.
  
          random_state : RandomState or an int seed
              A random number generator instance. If ``None``, the object's
              ``random_state`` is used.
  
          Returns
          -------
          X : array, shape (n_samples, n_features)
              Feature matrix.
  
          state_sequence : array, shape (n_samples, )
              State sequence produced by the model.