def get_features(self, batch: torch.Tensor) -> torch.Tensor:
        """Extract features from the pretrained network.

        Args:
            batch (torch.Tensor): Input video clips with shape
                ``(batch_size, num_clips, channels, height, width)``.

        Returns:
            torch.Tensor| Tuple[torch.Tensor, torch.Size]: Features during
                training, or tuple of (features, feature_shapes) during inference.
        """
        with torch.no_grad():
            self.feature_extractor.eval()
            batch = torch.permute(batch, (0, 2, 1, 3, 4))
            out_dict = self.feature_extractor(batch)
            if self.layer.startswith("features"):
                out = torch.permute(out_dict[self.layer], (0, 1, 4, 2, 3))
            else:
                out = out_dict[self.layer]
            # pool
            if self.spatial_pool:
                if len(out.shape) == 5:
                    pool_features = F.avg_pool3d(out, (1, self.pooling_kernel_size, self.pooling_kernel_size))
                elif len(out.shape) == 4:
                    pool_features = F.avg_pool2d(out, (self.pooling_kernel_size, self.pooling_kernel_size))
                else:
                    pool_features = F.avg_pool1d(out, self.pooling_kernel_size)
                feature_shape = pool_features.shape
            else:
                feature_shape = list(out.shape)
                fea_vector = out.reshape(feature_shape[0], -1)
                pool_features = F.avg_pool1d(fea_vector, self.pooling_kernel_size)
                feature_shape[1] = feature_shape[1] // self.pooling_kernel_size

        features = pool_features.detach().reshape(feature_shape[0], -1)
        return features, feature_shape
Extract features from the pretrained network.

        Args:
            batch (torch.Tensor): Input video clips with shape
                ``(batch_size, num_clips, channels, height, width)``.

        Returns:
            torch.Tensor| Tuple[torch.Tensor, torch.Size]: Features during
                training, or tuple of (features, feature_shapes) during inference.
        
src/anomalib/models/video/fuvas/torch_model.py