input: Write a function to implement a logistic regression classifier in Python to classify handwritten digits from the MNIST dataset. The function should load the MNIST dataset, prepare the data for logistic regression, and train the model with the training data. Finally, it should print the accuracy of the model on the training, validation, and test datasets.
  assert LogisticRegression(X_train, y_train, 1000, 0.001) != None
  assert train_accuracy > 0.85
  assert valid_accuracy > 0.85
  assert test_accuracy > 0.85
output: def LogisticRegression(X_train, y_train, num_iterations, learning_rate):
      import numpy as np
      from sklearn.linear_model import LogisticRegression
      from sklearn.model_selection import train_test_split
      from sklearn.metrics import accuracy_score
  
      # Prepare the data
      X_train, X_valid, y_train, y_valid = train_test_split(X_train, y_train, test_size=0.2, random_state=42)
  
      # Initialize the model
      model = LogisticRegression(max_iter=num_iterations, solver='saga', multi_class='multinomial', C=1/learning_rate)
  
      # Train the model
      model.fit(X_train, y_train)
  
      # Predict and calculate accuracy
      train_accuracy = accuracy_score(y_train, model.predict(X_train))
      valid_accuracy = accuracy_score(y_valid, model.predict(X_valid))
      test_accuracy = accuracy_score(y_test, model.predict(X_test))
  
      # Print the accuracies
      print(f"Training Accuracy: {train_accuracy:.4f}")
      print(f"Validation Accuracy: {valid_accuracy:.4f}")
      print(f"Test Accuracy: {test_accuracy:.4f}")
  
      return model