

'''simple docstring'''


from transformers import FSMTTokenizer, FSMTConfig, FSMTForConditionalGeneration

lowerCAmelCase__						:       Dict										=						"""facebook/wmt19-en-de"""
lowerCAmelCase__						:       Optional[int]										=						FSMTTokenizer.from_pretrained(mname)
# get the correct vocab sizes, etc. from the master model
lowerCAmelCase__						:       List[Any]										=						FSMTConfig.from_pretrained(mname)
config.update(
    dict(
        d_model=4,
        encoder_layers=1,
        decoder_layers=1,
        encoder_ffn_dim=4,
        decoder_ffn_dim=4,
        encoder_attention_heads=1,
        decoder_attention_heads=1,
    )
)

lowerCAmelCase__						:       Tuple										=						FSMTForConditionalGeneration(config)
print(f"""num of params {tiny_model.num_parameters()}""")

# Test
lowerCAmelCase__						:       Union[str, Any]										=						tokenizer(["""Making tiny model"""], return_tensors="""pt""")
lowerCAmelCase__						:       List[Any]										=						tiny_model(**batch)

print("""test output:""", len(outputs.logits[0]))

# Save
lowerCAmelCase__						:       Optional[int]										=						"""tiny-wmt19-en-de"""
tiny_model.half()  # makes it smaller
tiny_model.save_pretrained(mname_tiny)
tokenizer.save_pretrained(mname_tiny)

print(f"""Generated {mname_tiny}""")

# Upload
# transformers-cli upload tiny-wmt19-en-de






'''simple docstring'''


def 	_a       (				__lowerCAmelCase		:      float   ,							__lowerCAmelCase		:      float   ,							__lowerCAmelCase		:      int     ):

		"""simple docstring"""

		if principal <= 0:
				raise Exception('''Principal borrowed must be > 0'''     )
		if rate_per_annum < 0:
				raise Exception('''Rate of interest must be >= 0'''     )
		if years_to_repay <= 0 or not isinstance(__lowerCAmelCase   ,							__lowerCAmelCase     ):
				raise Exception('''Years to repay must be an integer > 0'''     )

		# Yearly rate is divided by 12 to get monthly rate
		snake_case__						:       int       						=  rate_per_annum / 12

		# Years to repay is multiplied by 12 to get number of payments as payment is monthly
		snake_case__						:       Tuple       						=  years_to_repay * 12

		return (
		    principal
		    * rate_per_month
		    * (1 + rate_per_month) ** number_of_payments
		    / ((1 + rate_per_month) ** number_of_payments - 1)
		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()



