def _save_pretrained()

in src/optimum/nvidia/hub.py [0:0]


    def _save_pretrained(self, save_directory: Path) -> None:
        device_name = get_device_name(0)[-1]
        save_directory = save_directory.joinpath(device_name)
        save_directory.mkdir(parents=True, exist_ok=True)

        src_license_file_path = self._engines_path.parent / FILE_LICENSE_NAME
        dst_files = [src_license_file_path] if src_license_file_path.exists() else []
        dst_files += list(self._engines_path.glob("*"))

        for file in dst_files:
            try:
                # Ensure target folder exists anyhow
                save_path = save_directory.joinpath(
                    file.relative_to(self._engines_path.parent)
                )
                save_path.parent.mkdir(parents=True, exist_ok=True)

                if not save_path.exists():
                    # Need target_is_directory on Windows
                    # Windows10 needs elevated privilege for symlink which will raise OSError if not the case
                    # Falling back to copytree in this case
                    symlink(file, save_path)
            except OSError as ose:
                LOGGER.error(
                    f"Failed to create symlink from current engine folder {self._engines_path.parent} to {save_directory}. "
                    "Will default to copy based _save_pretrained",
                    exc_info=ose,
                )

                dst = save_directory.joinpath(
                    file.relative_to(self._engines_path.parent)
                )
                if file.is_dir():
                    copytree(file, dst, symlinks=True)
                elif file:
                    copyfile(file, dst)

        self._save_additional_parcels(save_directory)