def _load_model_and_image_preprocessor_from_checkpoint(self) -> Tuple[torch.nn.Module, Compose]:
        """Load the model and image preprocessor from a checkpoint file.

        The checkpoint file can be provided through a URL or a model_location object.
        """
        # Load the image preprocessor
        if self.model_properties.localpath:
            if os.path.exists(self.model_properties.localpath):
                self.model_path = self.model_properties.localpath
            else:
                raise InvalidModelPropertiesError(
                    f"The localpath '{self.model_properties.localpath}' does not exist. "
                    f"Please provide a valid localpath to load the model. If you are running Marqo in a container, "
                    f"make sure the localpath is mounted correctly."
                )
        elif self.model_properties.model_location:
            self.model_path = self._download_from_repo()
        elif self.model_properties.url:
            self.model_path = download_model(url=self.model_properties.url)
        else:
            raise InternalError("One of 'localpath', 'model_location', or 'url' must be provided to load the model.")

        logger.info(f"The name of the custom clip model is {self.model_properties.name}. We use open_clip loader")

        try:
            self.image_preprocessor_config = self._aggregate_image_preprocessor_config()
            preprocess = image_transform_v2(self.image_preprocessor_config, is_train=False)
            model = self._create_model()
            return model, preprocess
        except Exception as e:
            # RuntimeError is raised by torch 1.12.1, UnpicklingError is raised by torch 1.13.1
            if isinstance(e, (RuntimeError, UnpicklingError)) and "The file might be corrupted" in str(e):
                try:
                    os.remove(self.model_path)
                except Exception as remove_e:
                    raise RuntimeError(
                        f"Marqo encountered an error while attempting to delete a corrupted file '{self.model_path}'. "
                        f"Please report this issue on Marqo's Github Repo and replace the problematic Marqo instance "
                        f"with a new one. \n "
                        f"Error message: `{str(remove_e)}`"
                    )
                raise InvalidModelPropertiesError(
                    f"Marqo encountered a corrupted file when loading open_clip file '{self.model_path}'. "
                    f"Marqo has removed this file from the disk. "
                    f"Some possible causes are: "
                    f"1. the file was not a valid open_clip checkpoint, "
                    f"2. the file was corrupted during download or incompletely downloaded, "
                    f"3. you may have tried to load a clip model even though model_properties['type'] is set to 'open_clip' "
                    f"Please check and update your model properties and retry. "
                    f"You can find more details at {marqo_docs.bring_your_own_model()}")
            # It is tricky to cacth the error when loading clip model using type = open_clip. Different pytorch version will raise different error.
            elif isinstance(e, (AttributeError, RuntimeError)) or (
                    "This could be because the operator doesn't exist for this backend" in str(e)):
                raise InvalidModelPropertiesError(
                    f"Marqo encountered an error when loading custom open_clip model '{self.model_properties.name}' with "
                    f"model properties = '{self.model_properties.dict()}'. "
                    f"The error message is {str(e)}. "
                    f"You may have tried to load a clip model even though model_properties['type'] is set to 'open_clip' "
                    f"Please check and update your model properties and retry. "
                    f"You can find more details at {marqo_docs.bring_your_own_model()}"
                )
            else:
                raise RuntimeError(
                    f"Marqo encountered an error when loading custom open_clip model {self.model_properties.name} with "
                    f"model properties = {self.model_properties.dict()}. "
                    f"The error message is {str(e)}. "
                    f"Please check and update your model properties and retry. "
                    f"You can find more details at {marqo_docs.bring_your_own_model()}"
                )
Load the model and image preprocessor from a checkpoint file.

        The checkpoint file can be provided through a URL or a model_location object.
        
src/marqo/inference/native_inference/embedding_models/open_clip_model.py