input: Write a function to construct a naive bayes classifier using python to classify emails as spam or not spam. The function should train the model using training data and then predict the output for test data. If the input data is missing or invalid, the function should return an appropriate error message.
  assert spam_classifier([[1, 'buy now'], [0, 'welcome']], [[1, 1, 'discount offer'], [0, 0, 'please attend']]) == 'Invalid input data format'
  assert spam_classifier([], [[1, 1, 'discount offer'], [0, 0, 'please attend']]) == 'Training data is empty'
  assert spam_classifier([[1, 'buy now'], [0, 'welcome']], [[1, 'discount offer'], [0, 'please attend']]) == 'Test data format does not match training data'
  assert spam_classifier([[1, 'buy now'], [0, 'welcome']], [[1, 1, 'discount offer'], [0, 0, 'please attend']]) == [1, 0]
output: def spam_classifier(training_data, test_data):
      if not training_data:
          return 'Training data is empty'
      if not all(len(entry) == 2 for entry in training_data):
          return 'Invalid input data format'
      if not all(len(entry) == 3 for entry in test_data):
          return 'Test data format does not match training data'
      
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.pipeline import make_pipeline
      
      X_train = [entry[1] for entry in training_data]
      y_train = [entry[0] for entry in training_data]
      X_test = [entry[2] for entry in test_data]
      
      model = make_pipeline(CountVectorizer(), MultinomialNB())
      model.fit(X_train, y_train)
      
      predictions = model.predict(X_test)
      return list(predictions)