keras/api_gen.py/update_package_init
def update_package_init(template_fname, dest_fname, api_module):
    with open(template_fname) as template_file:
        with open(dest_fname, "w") as dest_file:
            for line in template_file:
                if "# DO NOT EDIT." in line:
                    dest_file.write(line)
                    # Import all public symbols from `api/` and `__version__`.
                    for symbol in api_module.__dict__.keys():
                        if symbol.startswith("_") and symbol != "__version__":
                            continue
                        dest_file.write(f"from keras.api import {symbol}\n")
                    # Skip the previous autogenerated block.
                    for line in template_file:
                        if "# END DO NOT EDIT." in line:
                            break
                dest_file.write(line)