def train_valid_split(dataset, valid_ratio=<NUM_LIT>):
if not <NUM_LIT:0.0> <= valid_ratio <= <NUM_LIT:1.0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>num_train = len(dataset)<EOL>num_valid = np.ceil(num_train * valid_ratio).astype('<STR_LIT:int>')<EOL>indices = np.arange(num_train)<EOL>np.random.shuffle(indices)<EOL>valid = SimpleDataset([dataset[indices[i]] for i in range(num_valid)])<EOL>train = SimpleDataset([dataset[indices[i + num_valid]] for i in range(num_train - num_valid)])<EOL>return train, valid<EOL>
Split the dataset into training and validation sets.

    Parameters
    ----------
    dataset : list
        A list of training samples.
    valid_ratio : float, default 0.05
        Proportion of training samples to use for validation set
        range: [0, 1]

    Returns
    -------
    train : SimpleDataset
    valid : SimpleDataset