code: def text_generator(body: Body):
      input_length = len(body.text.split())
      tokens = app.tokenizer.encode(body.text, return_tensors="pt").to(
          app.device
      )
      prediction = app.model.generate(
          tokens, max_length=input_length + 20, do_sample=True
      )
      return {"text": app.tokenizer.decode(prediction[0])}
  
file_path: cortex/test/apis/async/text-generator/app/main.py
imports: import os
  from fastapi import FastAPI, status
  from fastapi.responses import PlainTextResponse
  from pydantic import BaseModel
  from transformers import GPT2Tokenizer, GPT2LMHeadModel
label_desc: Use image node_id 3 for calling a global function with example usage: text_generator(body) and returns: dict