Compute the compression ratio achieved by a historical context compression method in video generation. Given the original number of frames, the number of features per frame, and the compressed representation size (number of tokens), calculate the compression ratio.
def compression_ratio(
num_frames: int,
features_per_frame: int,
compressed_tokens: int
) -> float:
original_size = num_frames * features_per_frame
ratio = original_size / compressed_tokens
return round(ratio, 4)num_frames * features_per_frame total tokens/features.compressed_tokens tokens.