input: Write a python function to generate a response text using GPT-2 model with specified temperature and length.
  assert generate_response("I'm feeling sad.", 0.7, 30) is not None
  assert len(generate_response("Tell me a joke.", 0.7, 30)) > 0
  assert generate_response("Once upon a time", 0.7, 30).startswith("Once upon a time")
output: def generate_response(prompt, temperature, length):
      from transformers import GPT2LMHeadModel, GPT2Tokenizer
      import torch
  
      # Load pre-trained model and tokenizer
      model_name = 'gpt2'
      model = GPT2LMHeadModel.from_pretrained(model_name)
      tokenizer = GPT2Tokenizer.from_pretrained(model_name)
  
      # Encode the input prompt
      inputs = tokenizer.encode(prompt, return_tensors='pt')
  
      # Generate text
      outputs = model.generate(inputs, max_length=length + len(inputs[0]), temperature=temperature, num_return_sequences=1)
      
      # Decode the generated text
      response = tokenizer.decode(outputs[0], skip_special_tokens=True)
  
      return response