original_docstring: Gradient of mean squared error cost function with optional regularization.
  
          :param theta: ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: int, float; If value is passed, regularization term will be added.
          :return: ndarray; gradient
          
docstring: Gradient of mean squared error cost function with optional regularization.
docstring_tokens: Gradient of mean squared error cost function with optional regularization .
code: def mse_grad(theta, x, y, Lambda=None):
          """Gradient of mean squared error cost function with optional regularization.
  
          :param theta: ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: int, float; If value is passed, regularization term will be added.
          :return: ndarray; gradient
          """
          theta = theta.reshape(1, x.shape[1])
          grad = sum((x @ theta.T - y) * x) / len(x)
          if Lambda:
              grad += MLFuncts.regularize(theta, Lambda, x.shape[0], 'grad').flatten()
          return grad
code_tokens: def mse_grad ( theta , x , y , Lambda = None ) : theta = theta . reshape ( 1 , x . shape [ 1 ] ) grad = sum ( ( x @ theta . T - y ) * x ) / len ( x ) if Lambda : grad += MLFuncts . regularize ( theta , Lambda , x . shape [ 0 ] , 'grad' ) . flatten ( ) return grad
short_docstring: Gradient of mean squared error cost function with optional regularization.
short_docstring_tokens: Gradient of mean squared error cost function with optional regularization .
comment: """Gradient of mean squared error cost function with optional regularization.
  
          :param theta: ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: int, float; If value is passed, regularization term will be added.
          :return: ndarray; gradient
          """