input: Write a python function to train a neural network model using the provided code and save the model to a pickle file.
  assert train_and_save_model('data.json', 'model.pkl') == True
  assert train_and_save_model('data_invalid.json', 'model.pkl') == False
output: import json
  import pickle
  from sklearn.model_selection import train_test_split
  from sklearn.neural_network import MLPClassifier
  from sklearn.metrics import accuracy_score
  
  def train_and_save_model(data_file, model_file):
      try:
          with open(data_file, 'r') as f:
              data = json.load(f)
          
          X = data['features']
          y = data['labels']
          
          X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
          
          model = MLPClassifier(hidden_layer_sizes=(100,), max_iter=300, solver='adam', random_state=42)
          model.fit(X_train, y_train)
          
          y_pred = model.predict(X_test)
          accuracy = accuracy_score(y_test, y_pred)
          
          with open(model_file, 'wb') as f:
              pickle.dump(model, f)
          
          return True
      except Exception as e:
          print(f"Error: {e}")
          return False