    def load_pretrained_weights(self, pretrained=None, device=None):
        """Initialize the weights from pretrained weights.
        Args:
            pretrained (str, optional): Path to pre-trained weights.
                Defaults to None.
        """

        def map_state_dic(checkpoint):
            new_state_dict = OrderedDict()
            for k, v in checkpoint["state_dict"].items():
                name = k
                if "backbone" in k or "cls_head" in k:
                    name = name[9:]
                new_state_dict[name] = v
            return new_state_dict

        logging.info("load model from: %s", self.pretrained)
        if self.pretrained2d:
            # Inflate 2D model into 3D model.
            self.inflate_weights()
        else:
            # Directly load 3D model.
            checkpoint = model_zoo.load_url(pretrained, map_location=torch.device(device))
            new_state_dict = map_state_dic(checkpoint)
            self.load_state_dict(new_state_dict, strict=True)
Initialize the weights from pretrained weights.
Args:
pretrained (str, optional): Path to pre-trained weights.
Defaults to None.
towhee/models/video_swin_transformer/video_swin_transformer.py