input: Write a python function to implement gradient descent for linear regression and compute the cost using mean squared error.
  assert np.allclose(gd(np.array([1, 2, 3]), np.array([1, 2, 3]), 0.01, 10)[0], np.array([0.99]), rtol=1e-2)
  assert gd(np.array([1, 2, 3]), np.array([1, 2, 3]), 0.01, 10)[1][-1] < 0.1
  assert np.allclose(cost(np.array([1, 2, 3]), np.array([1, 2, 3]), np.array([1])), 0.0)
output: import numpy as np
  
  def cost(X, y, theta):
      m = len(y)
      predictions = X.dot(theta)
      cost = (1 / (2 * m)) * np.sum(np.square(predictions - y))
      return cost
  
  def gd(X, y, alpha, num_iters):
      m = len(y)
      X = X.reshape(m, 1)
      theta = np.zeros(1)
      J_history = []
      
      for i in range(num_iters):
          predictions = X.dot(theta)
          errors = predictions - y
          delta = (1 / m) * X.T.dot(errors)
          theta -= alpha * delta
          J_history.append(cost(X, y, theta))
      
      return theta, J_history