User trying to import a module that's not installed. Instead of bumping him and telling her to use a different workspace on which the module *is* installed, use compute resources to try and install.. nuts.. Starting with : from transformers import TFAutoModelForSeq2SeqLM, AutoTokenizer import gradio as gr model = TFAutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small") tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small") def gen_text(input_string, max_length): inputs = tokenizer(input_string, return_tensors="pt") outputs = model.generate(**inputs, max_length=max_length) final_text = tokenizer.batch_decode(outputs[0], skip_special_tokens=True) return (final_text) demo = gr.Interface( fn=gen_text, ...
Stub : 63 --> '(3**2)(7)' You get the idea. The return needs to be '(p1**n1)(p2**n2)..(pk**nk)' How? I admit my first shot was crappy - maintain a dictionary of powers. Then I saw the "best" solution : def primeFactors(n): ret = '' for i in xrange(2, n + 1): num = 0 while(n % i == 0): num += 1 n /= i if num > 0: ret += '({}{})'.format(i, '**%d' % num if num > 1 else '') if n == 1: return ret Hokay, what's going on here? Really cute way of building up the string as you go along. But, he looking at all the numbers from 2 to n. Do you need to? The even numbers? :) Once you've extracted 2, you'll never need to consider an even number again. Then, to what extend to you need to go? Do you need to go past sqrt(n)? Take 21. You get 3 out of it and stop at 5 because that's close to sqrt(21). What are you left with after yo...