code: def _generate_sequences(
      num_steps, transition_matrix, order, random_state
  ):
      elements = []
  
      num_states = transition_matrix.shape[0]
  
      transition_matrix = np.cumsum(transition_matrix, axis=1)
  
      rvs = random_state.rand(num_steps)
      state = random_state.randint(
          transition_matrix.shape[0], size=order, dtype=np.int64
      )
  
      for rv in rvs:
          row = transition_matrix[state].mean(axis=0)
          new_state = min(num_states - 1, np.searchsorted(row, rv))
  
          state[:-1] = state[1:]
          state[-1] = new_state
  
          elements.append(new_state)
  
      return np.array(elements, dtype=np.int32)
  
imports: import numpy
  from spotlight.interactions import Interactions
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_sequences(num_steps, transition_matrix, order, random_state) and returns: np