original_docstring: Returns gradient of sigmoid cost function. Regularization is optional.
  
          :param theta: (1, n) or (n,) ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: float; If 0 or None, regularization term won't be added.
          :return: ndarray; gradient.
          
docstring: Returns gradient of sigmoid cost function. Regularization is optional.
docstring_tokens: Returns gradient of sigmoid cost function . Regularization is optional .
code: def sigmoid_cost_grad(theta, x, y, Lambda=None):
          """Returns gradient of sigmoid cost function. Regularization is optional.
  
          :param theta: (1, n) or (n,) ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: float; If 0 or None, regularization term won't be added.
          :return: ndarray; gradient.
          """
          theta = theta.reshape(1, x.shape[1])
          grad = sum((MLFuncts.sigmoid(x @ theta.T) - y) * x) / x.shape[0]
  
          if Lambda:
              grad += MLFuncts.regularize(theta, Lambda, x.shape[0], 'grad').flatten()
          return grad
code_tokens: def sigmoid_cost_grad ( theta , x , y , Lambda = None ) : theta = theta . reshape ( 1 , x . shape [ 1 ] ) grad = sum ( ( MLFuncts . sigmoid ( x @ theta . T ) - y ) * x ) / x . shape [ 0 ] if Lambda : grad += MLFuncts . regularize ( theta , Lambda , x . shape [ 0 ] , 'grad' ) . flatten ( ) return grad
short_docstring: Returns gradient of sigmoid cost function.
short_docstring_tokens: Returns gradient of sigmoid cost function .
comment: """Returns gradient of sigmoid cost function. Regularization is optional.
  
          :param theta: (1, n) or (n,) ndarray; vector of weights.
          :param x: 2D ndarray; training data, examples in rows, features in cols.
          :param y: ndarray; (n, 1) shape.
          :param Lambda: float; If 0 or None, regularization term won't be added.
          :return: ndarray; gradient.
          """