    def _load_model(self, checkpoint_path=None, resume_type="resume"):
        """Load model from checkpoint. If checkpoint_path is None, it will
        load the latest checkpoint in checkpoint_dir. If checkpoint_path is not
        None, it will load the checkpoint specified by checkpoint_path. **Only use this
        method after** ``accelerator.prepare()``.
        """
        if resume_type == "resume":
            if checkpoint_path is None:
                available_checkpoints = glob.glob(
                    os.path.join(self.checkpoint_dir, "FAcodc_epoch_*_step_*.pth")
                )
                # find the checkpoint that has the highest step number
                latest_checkpoint = max(
                    available_checkpoints,
                    key=lambda x: int(x.split("_")[-1].split(".")[0]),
                )
                earliest_checkpoint = min(
                    available_checkpoints,
                    key=lambda x: int(x.split("_")[-1].split(".")[0]),
                )
                # delete the earliest checkpoint
                if (
                    earliest_checkpoint != latest_checkpoint
                    and self.accelerator.is_main_process
                    and len(available_checkpoints) > 4
                ):
                    os.remove(earliest_checkpoint)
                    print(f"Removed {earliest_checkpoint}")
            else:
                latest_checkpoint = checkpoint_path

            self.model, self.optimizer, self.epoch, self.step = load_checkpoint(
                self.model,
                self.optimizer,
                latest_checkpoint,
                load_only_params=False,
                ignore_modules=[],
                is_distributed=self.accelerator.num_processes > 1,
            )

        else:
            raise ValueError("Invalid resume type")
        return checkpoint_path
Load model from checkpoint. If checkpoint_path is None, it will
load the latest checkpoint in checkpoint_dir. If checkpoint_path is not
None, it will load the checkpoint specified by checkpoint_path. **Only use this
method after** ``accelerator.prepare()``.
models/codec/facodec/facodec_trainer.py