human
I wrote the below code

    datasets = load_data(mnist_pkl_gz)
    (train_set_x, train_set_y) = datasets[0]
    (valid_set_x, valid_set_y) = datasets[1]
    (test_set_x, test_set_y) = datasets[2]
    batch_size = 600
    n_train_batches = (train_set_x.get_value(borrow=True).shape[0] // batch_size)
    n_valid_batches = (valid_set_x.get_value(borrow=True).shape[0] // batch_size)
    n_test_batches = (test_set_x.get_value(borrow=True).shape[0] // batch_size)
    n_in = (28 * 28)
    n_out = 10
    print('...    building    the    model')
    minibatch_offset = T.lscalar()
    x = T.matrix()
    y = T.ivector()
    classifier = LogisticRegression(input=x, n_in=(28 * 28), n_out=10)
    cost = classifier.negative_log_likelihood(y).mean()
    test_model = theano.function([minibatch_offset], classifier.errors(y), givens={x: test_set_x[minibatch_offset:(minibatch_offset + batch_size)], y: test_set_y[minibatch_offset:(minibatch_offset + batch_size)]}, name='test')
    validate_model = theano.function([minibatch_offset], classifier.errors(y), givens={x: valid_set_x[minibatch_offset:(minibatch_offset + batch_size)], y: valid_set_y[minibatch_offset:(minibatch_offset + batch_size)]}, name='validate')
    batch_cost = theano.function([minibatch_offset], cost, givens={x: train_set_x[minibatch_offset:(minibatch_offset + batch_size)], y: train_set_y[minibatch_offset:(minibatch_offset + batch_size)]}, name='batch_cost')
    batch_grad = theano.function([minibatch_offset], T.grad(cost, classifier.theta), givens={x: train_set_x[minibatch_offset:(minibatch_offset + batch_size)], y: train_set_y[minibatch_offset:(minibatch_offset + batch_size)]}, name='batch_grad')
    def train_fn(theta_value):
        classifier.theta.set_value(theta_value, borrow=True)
        train_losses = [batch_cost((i * batch_size)) for i in range(n_train_batches)]
        return numpy.mean(train_losses)
    def train_fn_grad(theta_value):
        classifier.theta.set_value(theta_value, borrow=True)
        grad = batch_grad(0)
        for i in range(1, n_train_batches):
         ...

What's a good function header?
assistant
#Here's a good function header.

def cg_optimization_mnist(n_epochs=50, mnist_pkl_gz='mnist.pkl.gz'):