input: Write a python function to train a Naive Bayes classifier on a given set of training data and labels, then use it to predict the labels of a given set of test data.
  assert train_and_predict(['I love this movie', 'This movie is terrible'], [1, 0], ['I love it', 'It was terrible']) == [1, 0]
  assert train_and_predict(['Cats are great', 'Dogs are better'], [1, 0], ['I prefer cats', 'Dogs are amazing']) == [1, 0]
  assert train_and_predict(['Python is awesome', 'I hate bugs'], [1, 0], ['Python is great', 'Bugs are annoying']) == [1, 0]
output: def train_and_predict(train_data, train_labels, test_data):
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.naive_bayes import MultinomialNB
      
      # Convert the text data into a bag-of-words representation
      vectorizer = CountVectorizer()
      X_train = vectorizer.fit_transform(train_data)
      
      # Train the Naive Bayes classifier
      clf = MultinomialNB()
      clf.fit(X_train, train_labels)
      
      # Transform the test data into the same bag-of-words representation
      X_test = vectorizer.transform(test_data)
      
      # Predict the labels of the test data
      predictions = clf.predict(X_test)
      
      return predictions.tolist()