function op(f) {
    const keys = Object.keys(f);
    if (keys.length !== 1) throw new Error(`Please provide an object with a single key ` + `(operation name) mapping to a function. Got an object with ` + `${keys.length} keys.`);
    let opName = keys[0];
    const fn = f[opName];
    // Strip the underscore from the end of the function name.
    if (opName.endsWith("_")) opName = opName.substring(0, opName.length - 1);
    // add an __op suffix to distinguish ops from kernels in tf.profile
    opName = opName + OP_SCOPE_SUFFIX;
    // tslint:disable-next-line:no-any
    const f2 = (...args)=>{
        (0, _engine.ENGINE).startScope(opName);
        try {
            const result = fn(...args);
            if ((0, _util.isPromise)(result)) console.error("Cannot return a Promise inside of tidy.");
            (0, _engine.ENGINE).endScope(result);
            return result;
        } catch (ex) {
            (0, _engine.ENGINE).endScope(null);
            throw ex;
        }
    };
    Object.defineProperty(f2, "name", {
        value: opName,
        configurable: true
    });
    // tslint:disable-next-line:no-any
    return f2;
}
Used for wrapping functions that perform math operations on
Tensors. The function will be wrapped in a named scope that cleans all
memory usage after the function is done.