def update_file(path: Path, update_ckpts: bool) -> None:
    """Optimizes ipynb files in order to reduce further git diffs.
    Args:
        path: File to update, if this is file. If this is dir - recursively searches and updates .ipynb files in it.
        update_ckpts: If False and path is dir, will skip all found ipynb files from .ipynb_checkpoints.
    """
    if path.is_dir():
        logging.info(f"Updating .ipynb files in {path} dir"
                     f"{', excluding files from .ipynb_checkpoints subdirs' if update_ckpts is False else ''}.")
        for f in path.rglob('*.ipynb'):
            if update_ckpts is False and '.ipynb_checkpoints' in f.parts:
                continue
            update_file(f, update_ckpts)
    else:
        logging.info(f"Updating {path}.")
        nb = nbf.read(path, nbf.NO_CONVERT)
        merge_markdown(nb)
        drop_metadata(nb)
        with open(path, "w") as fout:
            nbf.write(nb, fout)
Optimizes ipynb files in order to reduce further git diffs.
    Args:
        path: File to update, if this is file. If this is dir - recursively searches and updates .ipynb files in it.
        update_ckpts: If False and path is dir, will skip all found ipynb files from .ipynb_checkpoints.
    
utils/prepare/optimize_ipynb.py