tests/transformers/roberta/test_modeling.py
def create_input_data(config, seed=None):
    '''
    the generated input data will be same if a specified seed is set 
    '''
    if seed is not None:
        np.random.seed(seed)

    input_ids = np.random.randint(
        low=0,
        high=config['vocab_size'],
        size=(config["batch_size"], config["seq_len"]))
    num_to_predict = int(config["seq_len"] * 0.15)
    masked_lm_positions = np.random.choice(
        config["seq_len"], (config["batch_size"], num_to_predict),
        replace=False)
    masked_lm_positions = np.sort(masked_lm_positions)
    pred_padding_len = config["seq_len"] - num_to_predict
    temp_masked_lm_positions = np.full(
        masked_lm_positions.size, 0, dtype=np.int32)
    mask_token_num = 0
    for i, x in enumerate(masked_lm_positions):
        for j, pos in enumerate(x):
            temp_masked_lm_positions[mask_token_num] = i * config[
                "seq_len"] + pos
            mask_token_num += 1
    masked_lm_positions = temp_masked_lm_positions
    return input_ids, masked_lm_positions

    the generated input data will be same if a specified seed is set 
    
the generated input data will be same if a specified seed is set
the generated input data will be same if a specified seed is set
def create_input_data(config, seed=None):
    if seed is not None:
        np.random.seed(seed)
    input_ids = np.random.randint(
        low=0,
        high=config['vocab_size'],
        size=(config["batch_size"], config["seq_len"]))
    num_to_predict = int(config["seq_len"] * 0.15)
    masked_lm_positions = np.random.choice(
        config["seq_len"], (config["batch_size"], num_to_predict),
        replace=False)
    masked_lm_positions = np.sort(masked_lm_positions)
    pred_padding_len = config["seq_len"] - num_to_predict
    temp_masked_lm_positions = np.full(
        masked_lm_positions.size, 0, dtype=np.int32)
    mask_token_num = 0
    for i, x in enumerate(masked_lm_positions):
        for j, pos in enumerate(x):
            temp_masked_lm_positions[mask_token_num] = i * config[
                "seq_len"] + pos
            mask_token_num += 1
    masked_lm_positions = temp_masked_lm_positions
    return input_ids, masked_lm_positions
def create_input_data ( config , seed = None ) : if seed is not None : np . random . seed ( seed ) input_ids = np . random . randint ( low = 0 , high = config [ 'vocab_size' ] , size = ( config [ "batch_size" ] , config [ "seq_len" ] ) ) num_to_predict = int ( config [ "seq_len" ] * 0.15 ) masked_lm_positions = np . random . choice ( config [ "seq_len" ] , ( config [ "batch_size" ] , num_to_predict ) , replace = False ) masked_lm_positions = np . sort ( masked_lm_positions ) pred_padding_len = config [ "seq_len" ] - num_to_predict temp_masked_lm_positions = np . full ( masked_lm_positions . size , 0 , dtype = np . int32 ) mask_token_num = 0 for i , x in enumerate ( masked_lm_positions ) : for j , pos in enumerate ( x ) : temp_masked_lm_positions [ mask_token_num ] = i * config [ "seq_len" ] + pos mask_token_num += 1 masked_lm_positions = temp_masked_lm_positions return input_ids , masked_lm_positions
the generated input data will be same if a specified seed is set
the generated input data will be same if a specified seed is set
'''
    the generated input data will be same if a specified seed is set 
    '''
config
seed