# Defining the Spark UDF def t5_seq2seq_udf(input_text): prompt = f"sentiment of the text: {input_text}" input = tokenizer(prompt, return_tensors="pt") output = model.generate(**input) output_text = tokenizer.decode(output[0], skip_special_tokens=True) return output_text