input: Write a python function to preprocess text data for a neural network model, including one-hot encoding, padding, and label encoding.
  assert preprocess_data([{'message': 'Hello world', 'label': 'greet'}, {'message': 'Goodbye world', 'label': 'farewell'}]) == (array([[ 0,  0, ...,  0,  9, 10], [ 0,  0, ...,  0, 11, 12]]), array([[1, 0], [0, 1]]))
  assert preprocess_data([{'message': 'Spam message', 'label': 'spam'}, {'message': 'Not spam message', 'label': 'not_spam'}]) == (array([[ 0,  0, ...,  0, 13, 14], [ 0,  0, ...,  0, 15, 16]]), array([[1, 0], [0, 1]]))
output: def preprocess_data(data):
      from keras.preprocessing.text import Tokenizer
      from keras.preprocessing.sequence import pad_sequences
      from sklearn.preprocessing import LabelEncoder
      from keras.utils import to_categorical
      import numpy as np
      
      # Extract messages and labels from the data
      messages = [item['message'] for item in data]
      labels = [item['label'] for item in data]
      
      # Tokenize the messages
      tokenizer = Tokenizer()
      tokenizer.fit_on_texts(messages)
      sequences = tokenizer.texts_to_sequences(messages)
      
      # Pad the sequences
      padded_sequences = pad_sequences(sequences, padding='post')
      
      # Encode the labels
      label_encoder = LabelEncoder()
      integer_encoded = label_encoder.fit_transform(labels)
      one_hot_labels = to_categorical(integer_encoded)
      
      return np.array(padded_sequences), np.array(one_hot_labels)