





"""simple docstring"""
import unittest

import numpy as np
import torch

from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()






class  _SCREAMING_SNAKE_CASE(       unittest.TestCase  ):




       @property
       def    _UpperCamelCase					(						self							)      ->				Dict:





             """simple docstring"""






             torch.manual_seed(0							)
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  UNetaDModel(
                 block_out_channels=(32, 64)		,layers_per_block=2		,sample_size=32		,in_channels=3		,out_channels=3		,down_block_types=('''DownBlock2D''', '''AttnDownBlock2D''')		,up_block_types=('''AttnUpBlock2D''', '''UpBlock2D''')		,)
             return model




       def    _UpperCamelCase					(						self							)      ->				Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Tuple		    =  self.dummy_uncond_unet
             __SCREAMING_SNAKE_CASE       :List[str]		    =  KarrasVeScheduler()

             __SCREAMING_SNAKE_CASE       :Dict		    =  KarrasVePipeline(unet=SCREAMING_SNAKE_CASE__		,scheduler=SCREAMING_SNAKE_CASE__							)
             pipe.to(SCREAMING_SNAKE_CASE__							)
             pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE       :Tuple		    =  torch.manual_seed(0							)
             __SCREAMING_SNAKE_CASE       :str		    =  pipe(num_inference_steps=2		,generator=SCREAMING_SNAKE_CASE__		,output_type='''numpy'''							).images

             __SCREAMING_SNAKE_CASE       :List[str]		    =  torch.manual_seed(0							)
             __SCREAMING_SNAKE_CASE       :Tuple		    =  pipe(num_inference_steps=2		,generator=SCREAMING_SNAKE_CASE__		,output_type='''numpy'''		,return_dict=SCREAMING_SNAKE_CASE__							)[0]

             __SCREAMING_SNAKE_CASE       :str		    =  image[0, -3:, -3:, -1]
             __SCREAMING_SNAKE_CASE       :Dict		    =  image_from_tuple[0, -3:, -3:, -1]

             assert image.shape == (1, 32, 32, 3)
             __SCREAMING_SNAKE_CASE       :Any		    =  np.array([0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]							)

             assert np.abs(image_slice.flatten() - expected_slice							).max() < 1E-2
             assert np.abs(image_from_tuple_slice.flatten() - expected_slice							).max() < 1E-2






@slow
@require_torch
class  _SCREAMING_SNAKE_CASE(       unittest.TestCase  ):




       def    _UpperCamelCase					(						self							)      ->				List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :str		    =  '''google/ncsnpp-celebahq-256'''
             __SCREAMING_SNAKE_CASE       :str		    =  UNetaDModel.from_pretrained(SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :List[str]		    =  KarrasVeScheduler()

             __SCREAMING_SNAKE_CASE       :Tuple		    =  KarrasVePipeline(unet=SCREAMING_SNAKE_CASE__		,scheduler=SCREAMING_SNAKE_CASE__							)
             pipe.to(SCREAMING_SNAKE_CASE__							)
             pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE       :List[str]		    =  torch.manual_seed(0							)
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  pipe(num_inference_steps=20		,generator=SCREAMING_SNAKE_CASE__		,output_type='''numpy'''							).images

             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  image[0, -3:, -3:, -1]
             assert image.shape == (1, 2_56, 2_56, 3)
             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  np.array([0.5_7_8, 0.5_8_1_1, 0.5_9_2_4, 0.5_8_0_9, 0.5_8_7, 0.5_8_8_6, 0.5_8_6_1, 0.5_8_0_2, 0.5_8_6]							)

             assert np.abs(image_slice.flatten() - expected_slice							).max() < 1E-2






"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase_       =		logging.get_logger(__name__)

lowerCamelCase_       =		{
    "google/vivit-b-16x2-kinetics400": (
        "https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json"
    ),
    # See all Vivit models at https://huggingface.co/models?filter=vivit
}






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				Optional[Any]     						=  '''vivit'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=2_24		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=[2, 16, 16]		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=30_72		,SCREAMING_SNAKE_CASE__="gelu_fast"		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1E-06		,SCREAMING_SNAKE_CASE__=True		,**SCREAMING_SNAKE_CASE__		,)      ->				str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  hidden_size
             __SCREAMING_SNAKE_CASE       :List[str]		    =  num_hidden_layers
             __SCREAMING_SNAKE_CASE       :List[str]		    =  num_attention_heads
             __SCREAMING_SNAKE_CASE       :Any		    =  intermediate_size
             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  hidden_act
             __SCREAMING_SNAKE_CASE       :int		    =  hidden_dropout_prob
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  attention_probs_dropout_prob
             __SCREAMING_SNAKE_CASE       :Dict		    =  initializer_range
             __SCREAMING_SNAKE_CASE       :Dict		    =  layer_norm_eps

             __SCREAMING_SNAKE_CASE       :Any		    =  image_size
             __SCREAMING_SNAKE_CASE       :Any		    =  num_frames
             __SCREAMING_SNAKE_CASE       :Any		    =  tubelet_size
             __SCREAMING_SNAKE_CASE       :Tuple		    =  num_channels
             __SCREAMING_SNAKE_CASE       :List[str]		    =  qkv_bias

             super().__init__(**SCREAMING_SNAKE_CASE__							)