    def encode_teacher(self, image):
        """encode image / videos as features.

        Args:
            image (torch.Tensor): The input images.

        Returns: tuple.
            - mask (torch.Tensor): Mask. Shape: [B,N1].
            - clip_output (torch.Tensor): The features of clip. Shape: [K,B,N,C].

        """
        B, C, T, H, W = image.shape
        mask_type = self.image_mask_type if T == 1 else self.video_mask_type
        window_size = self.image_window_size if T == 1 else self.video_window_size
        mask_ratio = self.image_mask_ratio if T == 1 else self.video_mask_ratio
        
        if self.clip_teacher is None or self.loss_weight.uta == 0:
            return None, None

        if H != self.clip_img_size:
            image = torch.nn.functional.interpolate(
                image.reshape(B, C*T, H, W), 
                size=(self.clip_img_size, self.clip_img_size), 
                mode='bicubic', align_corners=False
            )
            image = image.view(B, C, T, self.clip_img_size, self.clip_img_size)

        with torch.no_grad():
            if mask_type == 'tube':
                mask = TubeMaskingGenerator(window_size, mask_ratio, B)
                clip_output, attn = self.clip_teacher(image)
            elif mask_type == 'random':
                mask = RandomMaskingGenerator(window_size, mask_ratio, B)
                clip_output, attn = self.clip_teacher(image)
            elif mask_type in 'attention':
                clip_output, attn = self.clip_teacher(image)
                BT, N = attn.shape
                N_vis = N - int(N * mask_ratio)
                importance = torch.multinomial(attn, N)
                mask = torch.ones((BT, N))
                pos1 = torch.arange(BT).view(-1, 1).repeat(1, N_vis)
                pos2 = importance[:, :N_vis]
                mask[pos1, pos2] = 0
                mask = mask.view(B, -1).to(torch.bool)
            else:
                raise NotImplementedError
            
            # mask clip output
            K, _, _, C = clip_output.shape
            mask_clip = mask.unsqueeze(0).repeat(K, 1, 1)
            clip_output = clip_output[~mask_clip].reshape(K, B, -1, C)
        
        return mask, clip_output
encode image / videos as features.

Args:
image (torch.Tensor): The input images.

Returns: tuple.
- mask (torch.Tensor): Mask. Shape: [B,N1].
- clip_output (torch.Tensor): The features of clip. Shape: [K,B,N,C].
videomamba/video_mm/models/umt.py