




'''simple docstring'''


import torch

from transformers import CamembertForMaskedLM, CamembertTokenizer
def 						snake_case_       (UpperCamelCase			:    List[str]					,		UpperCamelCase			:    str					,		UpperCamelCase			:    int					,		UpperCamelCase			:    Optional[int]=5 ):





							'''simple docstring'''


							assert masked_input.count('''<mask>''' ) == 1
							_a      	=							torch.tensor(tokenizer.encode(UpperCamelCase					,		add_special_tokens=UpperCamelCase ) ).unsqueeze(0 )  # Batch size 1
							_a      	=							model(UpperCamelCase )[0]  # The last hidden-state is the first element of the output tuple
							_a      	=							(input_ids.squeeze() == tokenizer.mask_token_id).nonzero().item()
							_a      	=							logits[0, masked_index, :]
							_a      	=							logits.softmax(dim=0 )
							_a	,				_a      	=							prob.topk(k=UpperCamelCase					,		dim=0 )
							_a      	=							''' '''.join(
							    [tokenizer.convert_ids_to_tokens(indices[i].item() ) for i in range(len(UpperCamelCase ) )] )
							_a      	=							tokenizer.mask_token
							_a      	=							[]
							for index, predicted_token_bpe in enumerate(topk_predicted_token_bpe.split(''' ''' ) ):
														_a      	=							predicted_token_bpe.replace('''\u2581'''					,		''' ''' )
														if " {0}".format(UpperCamelCase ) in masked_input:
																					topk_filled_outputs.append(
																					    (
																					        masked_input.replace(''' {0}'''.format(UpperCamelCase )					,		UpperCamelCase ),
																					        values[index].item(),
																					        predicted_token,
																					    ) )
														else:
																					topk_filled_outputs.append(
																					    (
																					        masked_input.replace(UpperCamelCase					,		UpperCamelCase ),
																					        values[index].item(),
																					        predicted_token,
																					    ) )
							return topk_filled_outputs


_snake_case : Optional[Any]  				=						CamembertTokenizer.from_pretrained('camembert-base')
_snake_case : str  				=						CamembertForMaskedLM.from_pretrained('camembert-base')
model.eval()

_snake_case : str  				=						'Le camembert est <mask> :)'

print(fill_mask(masked_input, model, tokenizer, topk=3))



"""simple docstring"""



def 					lowerCamelCase   (     _snake_case    ,_snake_case ):
    return int((input_a, input_a).count(0 ) == 0 )
def 					lowerCamelCase   (     ):
    assert and_gate(0    ,0 ) == 0
    assert and_gate(0    ,1 ) == 0
    assert and_gate(1    ,0 ) == 0
    assert and_gate(1    ,1 ) == 1


if __name__ == "__main__":
    test_and_gate()
    print(and_gate(1, 0))
    print(and_gate(0, 0))
    print(and_gate(0, 1))
    print(and_gate(1, 1))

