def load_model(self, path: str | Path) -> nn.Module:
        """Load the PyTorch model.

        Args:
            path (str | Path): Path to the PyTorch model file.

        Returns:
            nn.Module: Loaded PyTorch model in evaluation mode.

        Raises:
            KeyError: If the checkpoint file does not contain a model.

        Example:
            >>> model = TorchInferencer(path="path/to/model.pt")
            >>> isinstance(model.model, nn.Module)
            True
        """
        checkpoint = self._load_checkpoint(path)
        if "model" not in checkpoint:
            msg = "``model`` not found in checkpoint. Please check the checkpoint file."
            raise KeyError(msg)

        model = checkpoint["model"]
        model.eval()
        return model.to(self.device)
Load the PyTorch model.

        Args:
            path (str | Path): Path to the PyTorch model file.

        Returns:
            nn.Module: Loaded PyTorch model in evaluation mode.

        Raises:
            KeyError: If the checkpoint file does not contain a model.

        Example:
            >>> model = TorchInferencer(path="path/to/model.pt")
            >>> isinstance(model.model, nn.Module)
            True
        
src/anomalib/deploy/inferencers/torch_inferencer.py