code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import torch
  
  from diffusers import DDIMScheduler
  
  from .test_schedulers import SchedulerCommonTest
  class 						__lowerCAmelCase   (			A_       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    List[str]     	=			(DDIMScheduler,)
    __lowerCamelCase       :    List[str]     	=			(("eta", 0.0), ("num_inference_steps", 50))
    def 					UpperCamelCase__   (      self:		List[Any]				,			**UpperCamelCase_:		str					):
       UpperCamelCase_     ={
           '''num_train_timesteps''': 1000,
           '''beta_start''': 0.0001,
           '''beta_end''': 0.02,
           '''beta_schedule''': '''linear''',
           '''clip_sample''': True,
       }
  
       config.update(**UpperCamelCase_					)
       return config
    def 					UpperCamelCase__   (      self:		str				,			**UpperCamelCase_:		int					):
       UpperCamelCase_     =self.scheduler_classes[0]
       UpperCamelCase_     =self.get_scheduler_config(**UpperCamelCase_					)
       UpperCamelCase_     =scheduler_class(**UpperCamelCase_					)
  
       UpperCamelCase_     =10, 0.0
  
       UpperCamelCase_     =self.dummy_model()
       UpperCamelCase_     =self.dummy_sample_deter
  
       scheduler.set_timesteps(UpperCamelCase_					)
  
       for t in scheduler.timesteps:
          UpperCamelCase_     =model(UpperCamelCase_				,			UpperCamelCase_					)
          UpperCamelCase_     =scheduler.step(UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_				,			UpperCamelCase_					).prev_sample
  
       return sample
    def 					UpperCamelCase__   (      self:		Dict					):
  
  
  
       for timesteps in [100, 500, 1000]:
          self.check_over_configs(num_train_timesteps=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		List[Any]					):
  
  
  
       for steps_offset in [0, 1]:
          self.check_over_configs(steps_offset=UpperCamelCase_					)
  
       UpperCamelCase_     =self.scheduler_classes[0]
       UpperCamelCase_     =self.get_scheduler_config(steps_offset=1					)
       UpperCamelCase_     =scheduler_class(**UpperCamelCase_					)
       scheduler.set_timesteps(5					)
       assert torch.equal(scheduler.timesteps				,			torch.LongTensor([801, 601, 401, 201, 1]					)					)
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
  
  
  
       for beta_start, beta_end in zip([0.0001, 0.001, 0.01, 0.1]				,			[0.002, 0.02, 0.2, 2]					):
          self.check_over_configs(beta_start=UpperCamelCase_				,			beta_end=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Any					):
  
  
  
       for schedule in ["linear", "squaredcos_cap_v2"]:
          self.check_over_configs(beta_schedule=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[int]					):
  
  
  
       for prediction_type in ["epsilon", "v_prediction"]:
          self.check_over_configs(prediction_type=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
  
  
  
       for clip_sample in [True, False]:
          self.check_over_configs(clip_sample=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Any					):
  
  
  
       for timestep_spacing in ["trailing", "leading"]:
          self.check_over_configs(timestep_spacing=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		List[str]					):
  
  
  
       for rescale_betas_zero_snr in [True, False]:
          self.check_over_configs(rescale_betas_zero_snr=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
       self.check_over_configs(thresholding=UpperCamelCase_					)
       for threshold in [0.5, 1.0, 2.0]:
          for prediction_type in ["epsilon", "v_prediction"]:
             self.check_over_configs(
                 thresholding=UpperCamelCase_				,			prediction_type=UpperCamelCase_				,			sample_max_value=UpperCamelCase_				,			)
    def 					UpperCamelCase__   (      self:		str					):
  
  
  
       for t in [1, 10, 49]:
          self.check_over_forward(time_step=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[int]					):
  
  
  
       for t, num_inference_steps in zip([1, 10, 50]				,			[10, 50, 500]					):
          self.check_over_forward(time_step=UpperCamelCase_				,			num_inference_steps=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
  
  
  
       for t, eta in zip([1, 10, 49]				,			[0.0, 0.5, 1.0]					):
          self.check_over_forward(time_step=UpperCamelCase_				,			eta=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		List[Any]					):
       UpperCamelCase_     =self.scheduler_classes[0]
       UpperCamelCase_     =self.get_scheduler_config()
       UpperCamelCase_     =scheduler_class(**UpperCamelCase_					)
  
       assert torch.sum(torch.abs(scheduler._get_variance(0				,			0					) - 0.0					)					) < 1e-5
       assert torch.sum(torch.abs(scheduler._get_variance(420				,			400					) - 0.1_4771					)					) < 1e-5
       assert torch.sum(torch.abs(scheduler._get_variance(980				,			960					) - 0.3_2460					)					) < 1e-5
       assert torch.sum(torch.abs(scheduler._get_variance(0				,			0					) - 0.0					)					) < 1e-5
       assert torch.sum(torch.abs(scheduler._get_variance(487				,			486					) - 0.0_0979					)					) < 1e-5
       assert torch.sum(torch.abs(scheduler._get_variance(999				,			998					) - 0.02					)					) < 1e-5
    def 					UpperCamelCase__   (      self:		List[Any]					):
       UpperCamelCase_     =self.full_loop()
  
       UpperCamelCase_     =torch.sum(torch.abs(UpperCamelCase_					)					)
       UpperCamelCase_     =torch.mean(torch.abs(UpperCamelCase_					)					)
  
       assert abs(result_sum.item() - 172.0067					) < 1e-2
       assert abs(result_mean.item() - 0.22_3967					) < 1e-3
    def 					UpperCamelCase__   (      self:		Union[str, Any]					):
       UpperCamelCase_     =self.full_loop(prediction_type="v_prediction"					)
  
       UpperCamelCase_     =torch.sum(torch.abs(UpperCamelCase_					)					)
       UpperCamelCase_     =torch.mean(torch.abs(UpperCamelCase_					)					)
  
       assert abs(result_sum.item() - 52.5302					) < 1e-2
       assert abs(result_mean.item() - 0.0684					) < 1e-3
    def 					UpperCamelCase__   (      self:		Any					):
       UpperCamelCase_     =self.full_loop(set_alpha_to_one=UpperCamelCase_				,			beta_start=0.01					)
       UpperCamelCase_     =torch.sum(torch.abs(UpperCamelCase_					)					)
       UpperCamelCase_     =torch.mean(torch.abs(UpperCamelCase_					)					)
  
       assert abs(result_sum.item() - 149.8295					) < 1e-2
       assert abs(result_mean.item() - 0.1951					) < 1e-3
  
  
  
  
  
    def 					UpperCamelCase__   (      self:		Any					):
       UpperCamelCase_     =self.full_loop(set_alpha_to_one=UpperCamelCase_				,			beta_start=0.01					)
       UpperCamelCase_     =torch.sum(torch.abs(UpperCamelCase_					)					)
       UpperCamelCase_     =torch.mean(torch.abs(UpperCamelCase_					)					)
  
       assert abs(result_sum.item() - 149.0784					) < 1e-2
       assert abs(result_mean.item() - 0.1941					) < 1e-3
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import warnings
  
  from ...processing_utils import ProcessorMixin
  from ...tokenization_utils_base import BatchEncoding
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    Optional[Any]     	=			["image_processor", "tokenizer"]
    __lowerCamelCase       :    List[str]     	=			"VideoMAEImageProcessor"
    __lowerCamelCase       :    Dict     	=			("CLIPTokenizer", "CLIPTokenizerFast")
    def __init__(      self:		str				,			UpperCamelCase_:		Dict=None				,			UpperCamelCase_:		str=None				,			**UpperCamelCase_:		str					):
       UpperCamelCase_     =None
       if "feature_extractor" in kwargs:
          warnings.warn(
              "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
              " instead."				,			UpperCamelCase_				,			)
          UpperCamelCase_     =kwargs.pop("feature_extractor"					)
  
       UpperCamelCase_     =image_processor if image_processor is not None else feature_extractor
       if image_processor is None:
          raise ValueError("You need to specify an `image_processor`."					)
       if tokenizer is None:
          raise ValueError("You need to specify a `tokenizer`."					)
  
       super().__init__(UpperCamelCase_				,			UpperCamelCase_					)
       UpperCamelCase_     =self.image_processor
    def __call__(      self:		Tuple				,			UpperCamelCase_:		str=None				,			UpperCamelCase_:		str=None				,			UpperCamelCase_:		Optional[Any]=None				,			**UpperCamelCase_:		int					):
  
       if text is None and videos is None:
          raise ValueError("You have to specify either text or videos. Both cannot be none."					)
  
       if text is not None:
          UpperCamelCase_     =self.tokenizer(UpperCamelCase_				,			return_tensors=UpperCamelCase_				,			**UpperCamelCase_					)
  
       if videos is not None:
          UpperCamelCase_     =self.image_processor(UpperCamelCase_				,			return_tensors=UpperCamelCase_				,			**UpperCamelCase_					)
  
       if text is not None and videos is not None:
          UpperCamelCase_     =image_features.pixel_values
          return encoding
       elif text is not None:
          return encoding
       else:
          return BatchEncoding(data=dict(**UpperCamelCase_					)				,			tensor_type=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Any				,			*UpperCamelCase_:		List[str]				,			**UpperCamelCase_:		Optional[int]					):
       return self.tokenizer.batch_decode(*UpperCamelCase_				,			**UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[Any]				,			*UpperCamelCase_:		List[str]				,			**UpperCamelCase_:		Tuple					):
       return self.tokenizer.decode(*UpperCamelCase_				,			**UpperCamelCase_					)
    @property
    def 					UpperCamelCase__   (      self:		List[Any]					):
       return ["input_ids", "attention_mask", "position_ids", "pixel_values"]
    @property
    def 					UpperCamelCase__   (      self:		str					):
       warnings.warn(
           "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."				,			UpperCamelCase_				,			)
       return self.image_processor_class
  
  
  
  
  
    @property
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
       warnings.warn(
           "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."				,			UpperCamelCase_				,			)
       return self.image_processor
  