input: Write a python function to train a Naive Bayes classifier using given training data and predict labels for given test data.
  assert train_and_predict(["This is a sample sentence.", "Another sample sentence.", "Yet another sentence for classification."], [0, 0, 1], ["Classify this sentence.", "Two sentences in one."]) == [1, 0]
  assert train_and_predict(["The quick brown fox", "jumps over the lazy dog", "hello world"], [0, 1, 0], ["quick brown", "lazy dog"]) == [0, 1]
  assert train_and_predict(["apple pie", "banana split", "cherry tart"], [1, 0, 1], ["apple", "banana"]) == [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
  
      # Vectorize the training data
      vectorizer = CountVectorizer()
      X_train = vectorizer.fit_transform(train_data)
      
      # Train the Naive Bayes classifier
      clf = MultinomialNB()
      clf.fit(X_train, train_labels)
      
      # Vectorize the test data
      X_test = vectorizer.transform(test_data)
      
      # Predict the labels for test data
      predictions = clf.predict(X_test)
      
      return predictions.tolist()