def encode_video_frames(self, video_frames: torch.FloatTensor) -> torch.FloatTensor:
        """
        Encode video frames into latent space using Variational Autoencoder.

        Args:
            video_frames (`torch.FloatTensor`):
                Input frames tensor in `[F, C, H, W]` format from `get_video_frames()`

        Returns:
            `torch.FloatTensor`: Encoded latents in `[1, F, D, H_latent, W_latent]` format where:
            - `F`: Number of frames (same as input)
            - `D`: Latent channel dimension
            - `H_latent`: Latent space height (H // 2^vae.downscale_factor)
            - `W_latent`: Latent space width (W // 2^vae.downscale_factor)
        """
        vae: AutoencoderKLCogVideoX = self.vae
        video_frames = video_frames.to(device=vae.device, dtype=vae.dtype)
        video_frames = video_frames.unsqueeze(0).permute(0, 2, 1, 3, 4)  # [B, C, F, H, W]
        latent_dist = vae.encode(x=video_frames).latent_dist.sample().transpose(1, 2)
        return latent_dist * vae.config.scaling_factor

        Encode video frames into latent space using Variational Autoencoder.

        Args:
            video_frames (`torch.FloatTensor`):
                Input frames tensor in `[F, C, H, W]` format from `get_video_frames()`

        Returns:
            `torch.FloatTensor`: Encoded latents in `[1, F, D, H_latent, W_latent]` format where:
            - `F`: Number of frames (same as input)
            - `D`: Latent channel dimension
            - `H_latent`: Latent space height (H // 2^vae.downscale_factor)
            - `W_latent`: Latent space width (W // 2^vae.downscale_factor)
        
examples/community/cogvideox_ddim_inversion.py