input: Write a python function to implement logistic regression and calculate accuracies on training, validation, and test sets.
  assert np.allclose(LogisticRegression(X_train, y_train, 1000, 0.001), weights)
  assert round(train_accuracy, 2) == 0.89
  assert round(valid_accuracy, 2) == 0.88
  assert round(test_accuracy, 2) == 0.88
output: import numpy as np
  
  def sigmoid(z):
      return 1 / (1 + np.exp(-z))
  
  def predict(X, weights):
      return sigmoid(np.dot(X, weights))
  
  def LogisticRegression(X_train, y_train, num_iterations, learning_rate):
      weights = np.zeros(X_train.shape[1])
      for i in range(num_iterations):
          predictions = predict(X_train, weights)
          errors = y_train - predictions
          gradient = np.dot(X_train.T, errors) / len(y_train)
          weights += learning_rate * gradient
      return weights
  
  def calculate_accuracy(X, y, weights):
      predictions = predict(X, weights) >= 0.5
      accuracy = np.mean(predictions == y)
      return accuracy
  
  # Assuming X_train, y_train, X_valid, y_valid, X_test, y_test are defined
  weights = LogisticRegression(X_train, y_train, 1000, 0.001)
  
  train_accuracy = calculate_accuracy(X_train, y_train, weights)
  valid_accuracy = calculate_accuracy(X_valid, y_valid, weights)
  test_accuracy = calculate_accuracy(X_test, y_test, weights)
  
  train_accuracy, valid_accuracy, test_accuracy