def _load_from_state_dict(self, state_dict: dict, prefix: str, *args) -> None:
        """Load a state dictionary, resizing buffers if shapes don't match.

        This method overrides the parent class implementation to handle tensor
        shape mismatches when loading state dictionaries. It resizes any local
        buffers whose shapes don't match the corresponding tensors in the state
        dict.

        Args:
            state_dict (dict): Dictionary containing state to load
            prefix (str): Prefix to prepend to parameter/buffer names
            *args: Additional arguments passed to parent implementation
        """
        persistent_buffers = {k: v for k, v in self._buffers.items() if k not in self._non_persistent_buffers_set}
        local_buffers = {k: v for k, v in persistent_buffers.items() if v is not None}

        for param in local_buffers:
            for key in state_dict:
                if (
                    key.startswith(prefix)
                    and key[len(prefix) :].split(".")[0] == param
                    and local_buffers[param].shape != state_dict[key].shape
                ):
                    attribute = self.get_tensor_attribute(param)
                    attribute.resize_(state_dict[key].shape)

        super()._load_from_state_dict(state_dict, prefix, *args)
Load a state dictionary, resizing buffers if shapes don't match.

        This method overrides the parent class implementation to handle tensor
        shape mismatches when loading state dictionaries. It resizes any local
        buffers whose shapes don't match the corresponding tensors in the state
        dict.

        Args:
            state_dict (dict): Dictionary containing state to load
            prefix (str): Prefix to prepend to parameter/buffer names
            *args: Additional arguments passed to parent implementation
        
src/anomalib/models/components/base/dynamic_buffer.py