import gradio as gr from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer model_name = "dsfsi/nso-en-m2m100-gov" tokenizer = M2M100Tokenizer.from_pretrained(model_name) model = M2M100ForConditionalGeneration.from_pretrained(model_name) print(tokenizer.lang_code_to_token) tokenizer.src_lang = "ns" model.config.forced_bos_token_id = tokenizer.get_lang_id("en") def translate(inp): inputs = tokenizer(inp, return_tensors="pt") translated_tokens = model.generate(**inputs, max_length=512, forced_bos_token_id=tokenizer.get_lang_id("en")) translated_text = tokenizer.decode(translated_tokens[0], skip_special_tokens=True) return translated_text description = """