
from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel
from ...schedulers import PNDMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput



class       a_   ( A__						):
			a  : Union[str, Any]				      =       4_2
			a  : str				      =       4_2






			def __init__(			self							, __UpperCamelCase							, __UpperCamelCase     ):
									super().__init__()

									_lowercase									=				PNDMScheduler.from_config(scheduler.config     )

									self.register_modules(unet=_lowerCAmelCase							, scheduler=_lowerCAmelCase     )






			@torch.no_grad()
			def __call__(			self							, __UpperCamelCase = 1							, __UpperCamelCase = 50							, __UpperCamelCase = None							, __UpperCamelCase = "pil"							, __UpperCamelCase = True							, **__UpperCamelCase							, ):
									_lowercase									=				randn_tensor(
									    (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)							, generator=_lowerCAmelCase							, device=self.device							, )

									self.scheduler.set_timesteps(_lowerCAmelCase     )
									for t in self.progress_bar(self.scheduler.timesteps     ):
															_lowercase									=				self.unet(_lowerCAmelCase							, _lowerCAmelCase     ).sample

															_lowercase									=				self.scheduler.step(_lowerCAmelCase							, _lowerCAmelCase							, _lowerCAmelCase     ).prev_sample

									_lowercase									=				(image / 2 + 0.5).clamp(0							, 1     )
									_lowercase									=				image.cpu().permute(0							, 2							, 3							, 1     ).numpy()
									if output_type == "pil":
															_lowercase									=				self.numpy_to_pil(_lowerCAmelCase     )

									if not return_dict:
															return (image,)

									return ImagePipelineOutput(images=_lowerCAmelCase     )






from ...configuration_utils import PretrainedConfig
from ...utils import logging


A		:   List[Any]         =    logging.get_logger(__name__)

A		:   str         =    {
    '''MCG-NJU/videomae-base''': '''https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json''',
}



class       a_   ( _a						):
			a  : str				      =       '''videomae'''






			def __init__(			self							, __UpperCamelCase=224							, __UpperCamelCase=16							, __UpperCamelCase=3							, __UpperCamelCase=16							, __UpperCamelCase=2							, __UpperCamelCase=768							, __UpperCamelCase=12							, __UpperCamelCase=12							, __UpperCamelCase=3_072							, __UpperCamelCase="gelu"							, __UpperCamelCase=0.0							, __UpperCamelCase=0.0							, __UpperCamelCase=0.02							, __UpperCamelCase=1E-12							, __UpperCamelCase=True							, __UpperCamelCase=True							, __UpperCamelCase=6							, __UpperCamelCase=384							, __UpperCamelCase=4							, __UpperCamelCase=1_536							, __UpperCamelCase=True							, **__UpperCamelCase							, ):
									super().__init__(**__UpperCamelCase     )

									_lowercase									=				image_size
									_lowercase									=				patch_size
									_lowercase									=				num_channels
									_lowercase									=				num_frames
									_lowercase									=				tubelet_size

									_lowercase									=				hidden_size
									_lowercase									=				num_hidden_layers
									_lowercase									=				num_attention_heads
									_lowercase									=				intermediate_size
									_lowercase									=				hidden_act
									_lowercase									=				hidden_dropout_prob
									_lowercase									=				attention_probs_dropout_prob
									_lowercase									=				initializer_range
									_lowercase									=				layer_norm_eps
									_lowercase									=				qkv_bias
									_lowercase									=				use_mean_pooling

									_lowercase									=				decoder_num_attention_heads
									_lowercase									=				decoder_hidden_size
									_lowercase									=				decoder_num_hidden_layers
									_lowercase									=				decoder_intermediate_size
									_lowercase									=				norm_pix_loss