p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] test.py (python)

import numpy as np

# Define parameters
B = 12  # Batch size
T = 16  # Time steps
N = 100  # Number of video tokens
M = 128  # Model dimension
max_noise_level = 0.7
noise_buckets = 10

# Initialize random seed for reproducibility
np.random.seed(42)

# Generate random noise level
noise_level_B = np.random.uniform(0.0, max_noise_level, size=(B,))

# Generate random noise
noise_BTNM = np.random.normal(size=(B, T, N, M))

# Calculate noise bucket indices
noise_bucket_idx_B = np.floor((noise_level_B / max_noise_level) * noise_buckets).astype(np.int32)
noise_bucket_idx_B11 = noise_bucket_idx_B.reshape(B, 1, 1)

# Simulate noise level embedding
noise_level_embed_B11M = np.random.normal(size=(B, 1, 1, M))  # Random embedding for testing
noise_level_embed_BT1M = np.tile(noise_level_embed_B11M, (1, T, 1, 1))

# Simulate video embedding
vid_embed_BTNM = np.random.normal(size=(B, T, N, M))

# Apply noise to video embedding
vid_embed_BTNM = np.sqrt(noise_level_B)[:, None, None, None] * vid_embed_BTNM + \
                 np.sqrt(1 - noise_level_B)[:, None, None, None] * noise_BTNM

# Print results for verification
print("Noise Level B:", noise_level_B.shape)
print("Noise Bucket Index B:", noise_bucket_idx_B.shape)
print("Noise Level Embed BT1M:", noise_level_embed_BT1M.shape)
print("Video Embed BTNM after noise application:", vid_embed_BTNM.shape)