minimize(f, returnCost = false, varList) {
        const { value, grads } = this.computeGradients(f, varList);
        if (varList != null) {
            const gradArray = varList.map((v)=>({
                    name: v.name,
                    tensor: grads[v.name]
                }));
            this.applyGradients(gradArray);
        } else this.applyGradients(grads);
        // Dispose gradients.
        (0, _globals.dispose)(grads);
        if (returnCost) return value;
        else {
            value.dispose();
            return null;
        }
    }
Executes `f()` and minimizes the scalar output of `f()` by computing
gradients of y with respect to the list of trainable variables provided by
`varList`. If no list is provided, it defaults to all trainable variables.

@param f The function to execute and whose output to minimize.
@param returnCost Whether to return the scalar cost value produced by
executing `f()`.
@param varList An optional list of variables to update. If specified, only
the trainable variables in varList will be updated by minimize. Defaults to
all trainable variables.

@doc {heading: 'Training', subheading: 'Optimizers'}