keras/pip_build.py/move_tf_keras_directory
def move_tf_keras_directory():
    """Move `keras/api/_tf_keras` to `keras/_tf_keras`, update references."""
    shutil.move(os.path.join(package, "api", "_tf_keras"), "keras")
    with open(os.path.join(package, "api", "__init__.py")) as f:
        contents = f.read()
        contents = contents.replace("from keras.api import _tf_keras", "")
    with open(os.path.join(package, "api", "__init__.py"), "w") as f:
        f.write(contents)
    # Replace `keras.api._tf_keras` with `keras._tf_keras`.
    for root, _, fnames in os.walk(os.path.join(package, "_tf_keras")):
        for fname in fnames:
            if fname.endswith(".py"):
                tf_keras_fpath = os.path.join(root, fname)
                with open(tf_keras_fpath) as f:
                    contents = f.read()
                    contents = contents.replace(
                        "keras.api._tf_keras", "keras._tf_keras"
                    )
                with open(tf_keras_fpath, "w") as f:
                    f.write(contents)