<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw_samples(self, sequences, n_samples, random_state=None):
 """Sample conformations for a sequences of states. Parameters sequences : list or list of lists A sequence or list of sequences, in which each element corresponds to a state label. n_samples : int How many samples to return for any given state. Returns ------- selected_pairs_by_state : np.array, dtype=int, shape=(n_states, n_samples, 2) selected_pairs_by_state[state] gives an array of randomly selected (trj, frame) pairs from the specified state. See Also -------- utils.map_drawn_samples : Extract conformations from MD trajectories by index. """

        if not any([isinstance(seq, collections.Iterable)
                    for seq in sequences]):
            sequences = [sequences]

        random = check_random_state(random_state)

        selected_pairs_by_state = []
        for state in range(self.n_states_):
            all_frames = [np.where(a == state)[0] for a in sequences]
            pairs = [(trj, frame) for (trj, frames) in enumerate(all_frames)
                     for frame in frames]
            if pairs:
                selected_pairs_by_state.append(
                        [pairs[random.choice(len(pairs))]
                         for i in range(n_samples)])
            else:
                selected_pairs_by_state.append([])

        return np.array(selected_pairs_by_state)