





'''simple docstring'''

import os
import tempfile
import unittest

from transformers import DistilBertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      DistilBertForMaskedLM,
      DistilBertForMultipleChoice,
      DistilBertForQuestionAnswering,
      DistilBertForSequenceClassification,
      DistilBertForTokenClassification,
      DistilBertModel,
  )






class        UpperCAmelCase     (	UpperCamelCase__    ):
 def __init__(    self				:Dict						,	lowercase_				:List[Any]						,	lowercase_				:str=13						,	lowercase_				:int=7						,	lowercase_				:Optional[Any]=True						,	lowercase_				:Tuple=True						,	lowercase_				:Union[str, Any]=False						,	lowercase_				:Optional[Any]=True						,	lowercase_				:Optional[Any]=99						,	lowercase_				:Optional[int]=32						,	lowercase_				:Union[str, Any]=5						,	lowercase_				:int=4						,	lowercase_				:Any=37						,	lowercase_				:Optional[int]="gelu"						,	lowercase_				:Optional[Any]=0.1						,	lowercase_				:List[Any]=0.1						,	lowercase_				:List[Any]=5_12						,	lowercase_				:str=16						,	lowercase_				:Optional[Any]=2						,	lowercase_				:List[str]=0.0_2						,	lowercase_				:Optional[Any]=3						,	lowercase_				:Tuple=4						,	lowercase_				:Union[str, Any]=None						,	)->							Dict:
     A__    =      parent
     A__    =      batch_size
     A__    =      seq_length
     A__    =      is_training
     A__    =      use_input_mask
     A__    =      use_token_type_ids
     A__    =      use_labels
     A__    =      vocab_size
     A__    =      hidden_size
     A__    =      num_hidden_layers
     A__    =      num_attention_heads
     A__    =      intermediate_size
     A__    =      hidden_act
     A__    =      hidden_dropout_prob
     A__    =      attention_probs_dropout_prob
     A__    =      max_position_embeddings
     A__    =      type_vocab_size
     A__    =      type_sequence_label_size
     A__    =      initializer_range
     A__    =      num_labels
     A__    =      num_choices
     A__    =      scope
 def 					UpperCAmelCase_							(    self				:List[str]							)->							List[Any]:
     A__    =      ids_tensor([self.batch_size, self.seq_length]						,	self.vocab_size							)

     A__    =      None
     if self.use_input_mask:
         A__    =      random_attention_mask([self.batch_size, self.seq_length]							)

     A__    =      None
     A__    =      None
     A__    =      None
     if self.use_labels:
         A__    =      ids_tensor([self.batch_size]						,	self.type_sequence_label_size							)
         A__    =      ids_tensor([self.batch_size, self.seq_length]						,	self.num_labels							)
         A__    =      ids_tensor([self.batch_size]						,	self.num_choices							)

     A__    =      self.get_config()

     return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels
 def 					UpperCAmelCase_							(    self				:Optional[Any]							)->							Optional[Any]:
     return DistilBertConfig(
         vocab_size=self.vocab_size						,	dim=self.hidden_size						,	n_layers=self.num_hidden_layers						,	n_heads=self.num_attention_heads						,	hidden_dim=self.intermediate_size						,	hidden_act=self.hidden_act						,	dropout=self.hidden_dropout_prob						,	attention_dropout=self.attention_probs_dropout_prob						,	max_position_embeddings=self.max_position_embeddings						,	initializer_range=self.initializer_range						,	)
 def 					UpperCAmelCase_							(    self				:Union[str, Any]						,	lowercase_				:Optional[int]						,	lowercase_				:int						,	lowercase_				:List[str]						,	lowercase_				:int						,	lowercase_				:int						,	lowercase_				:Union[str, Any]							)->							List[str]:
     A__    =      DistilBertModel(config=lowercase_							)
     model.to(lowercase_							)
     model.eval()
     A__    =      model(lowercase_						,	lowercase_							)
     A__    =      model(lowercase_							)
     self.parent.assertEqual(result.last_hidden_state.shape						,	(self.batch_size, self.seq_length, self.hidden_size)							)
 def 					UpperCAmelCase_							(    self				:List[str]						,	lowercase_				:List[Any]						,	lowercase_				:Dict						,	lowercase_				:List[Any]						,	lowercase_				:Dict						,	lowercase_				:Tuple						,	lowercase_				:List[Any]							)->							Optional[int]:
     A__    =      DistilBertForMaskedLM(config=lowercase_							)
     model.to(lowercase_							)
     model.eval()
     A__    =      model(lowercase_						,	attention_mask=lowercase_						,	labels=lowercase_							)
     self.parent.assertEqual(result.logits.shape						,	(self.batch_size, self.seq_length, self.vocab_size)							)
 def 					UpperCAmelCase_							(    self				:Dict						,	lowercase_				:Optional[int]						,	lowercase_				:Optional[int]						,	lowercase_				:Any						,	lowercase_				:str						,	lowercase_				:Tuple						,	lowercase_				:Union[str, Any]							)->							int:
     A__    =      DistilBertForQuestionAnswering(config=lowercase_							)
     model.to(lowercase_							)
     model.eval()
     A__    =      model(
         lowercase_						,	attention_mask=lowercase_						,	start_positions=lowercase_						,	end_positions=lowercase_							)
     self.parent.assertEqual(result.start_logits.shape						,	(self.batch_size, self.seq_length)							)
     self.parent.assertEqual(result.end_logits.shape						,	(self.batch_size, self.seq_length)							)
 def 					UpperCAmelCase_							(    self				:List[str]						,	lowercase_				:str						,	lowercase_				:int						,	lowercase_				:Tuple						,	lowercase_				:List[Any]						,	lowercase_				:Any						,	lowercase_				:Union[str, Any]							)->							Dict:
     A__    =      self.num_labels
     A__    =      DistilBertForSequenceClassification(lowercase_							)
     model.to(lowercase_							)
     model.eval()
     A__    =      model(lowercase_						,	attention_mask=lowercase_						,	labels=lowercase_							)
     self.parent.assertEqual(result.logits.shape						,	(self.batch_size, self.num_labels)							)
 def 					UpperCAmelCase_							(    self				:Dict						,	lowercase_				:str						,	lowercase_				:Optional[int]						,	lowercase_				:Tuple						,	lowercase_				:Tuple						,	lowercase_				:Union[str, Any]						,	lowercase_				:Union[str, Any]							)->							Union[str, Any]:
     A__    =      self.num_labels
     A__    =      DistilBertForTokenClassification(config=lowercase_							)
     model.to(lowercase_							)
     model.eval()

     A__    =      model(lowercase_						,	attention_mask=lowercase_						,	labels=lowercase_							)
     self.parent.assertEqual(result.logits.shape						,	(self.batch_size, self.seq_length, self.num_labels)							)
 def 					UpperCAmelCase_							(    self				:Tuple						,	lowercase_				:Tuple						,	lowercase_				:Dict						,	lowercase_				:Optional[int]						,	lowercase_				:Optional[int]						,	lowercase_				:int						,	lowercase_				:Union[str, Any]							)->							Any:
     A__    =      self.num_choices
     A__    =      DistilBertForMultipleChoice(config=lowercase_							)
     model.to(lowercase_							)
     model.eval()
     A__    =      input_ids.unsqueeze(1							).expand(-1						,	self.num_choices						,	-1							).contiguous()
     A__    =      input_mask.unsqueeze(1							).expand(-1						,	self.num_choices						,	-1							).contiguous()
     A__    =      model(
         lowercase_						,	attention_mask=lowercase_						,	labels=lowercase_						,	)
     self.parent.assertEqual(result.logits.shape						,	(self.batch_size, self.num_choices)							)



 def 					UpperCAmelCase_							(    self				:Optional[int]							)->							Tuple:
     A__    =      self.prepare_config_and_inputs()
     ((A__),     (A__),     (A__),     (A__),     (A__),     (A__))    =      config_and_inputs
     A__    =      {"input_ids": input_ids, "attention_mask": input_mask}
     return config, inputs_dict






@require_torch
class        UpperCAmelCase     (	UpperCamelCase__      ,	UpperCamelCase__      ,	unittest.TestCase    ):
 __lowercase       		=    (
     (
         DistilBertModel,
         DistilBertForMaskedLM,
         DistilBertForMultipleChoice,
         DistilBertForQuestionAnswering,
         DistilBertForSequenceClassification,
         DistilBertForTokenClassification,
     )
     if is_torch_available()
     else None
 )
 __lowercase       		=    (
     {
         """feature-extraction""": DistilBertModel,
         """fill-mask""": DistilBertForMaskedLM,
         """question-answering""": DistilBertForQuestionAnswering,
         """text-classification""": DistilBertForSequenceClassification,
         """token-classification""": DistilBertForTokenClassification,
         """zero-shot""": DistilBertForSequenceClassification,
     }
     if is_torch_available()
     else {}
 )
 __lowercase       		=    True
 __lowercase       		=    True
 __lowercase       		=    True
 __lowercase       		=    True
 def 					UpperCAmelCase_							(    self				:List[Any]							)->							str:
     A__    =      DistilBertModelTester(self							)
     A__    =      ConfigTester(self						,	config_class=lowercase_						,	dim=37							)
 def 					UpperCAmelCase_							(    self				:Tuple							)->							Union[str, Any]:
     self.config_tester.run_common_tests()
 def 					UpperCAmelCase_							(    self				:List[str]							)->							Any:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_model(*lowercase_							)
 def 					UpperCAmelCase_							(    self				:str							)->							Any:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_for_masked_lm(*lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[Any]							)->							Dict:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_for_question_answering(*lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[Any]							)->							List[str]:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_for_sequence_classification(*lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[str]							)->							Dict:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_for_token_classification(*lowercase_							)
 def 					UpperCAmelCase_							(    self				:Optional[int]							)->							str:
     A__    =      self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_distilbert_for_multiple_choice(*lowercase_							)
 @slow
 def 					UpperCAmelCase_							(    self				:Tuple							)->							Optional[Any]:
     for model_name in DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         A__    =      DistilBertModel.from_pretrained(lowercase_							)
         self.assertIsNotNone(lowercase_							)



 @slow
 @require_torch_gpu
 def 					UpperCAmelCase_							(    self				:Optional[int]							)->							int:
     A__,     A__    =      self.model_tester.prepare_config_and_inputs_for_common()
     for model_class in self.all_model_classes:
         # BertForMultipleChoice behaves incorrectly in JIT environments.
         if model_class == DistilBertForMultipleChoice:
             return

         A__    =      True
         A__    =      model_class(config=lowercase_							)

         A__    =      self._prepare_for_class(lowercase_						,	lowercase_							)
         A__    =      torch.jit.trace(
             lowercase_						,	(inputs_dict["input_ids"].to("cpu"							), inputs_dict["attention_mask"].to("cpu"							))							)

         with tempfile.TemporaryDirectory() as tmp:
             torch.jit.save(lowercase_						,	os.path.join(lowercase_						,	"traced_model.pt"							)							)
             A__    =      torch.jit.load(os.path.join(lowercase_						,	"traced_model.pt"							)						,	map_location=lowercase_							)
             loaded(inputs_dict["input_ids"].to(lowercase_							)						,	inputs_dict["attention_mask"].to(lowercase_							)							)






@require_torch
class        UpperCAmelCase     (	unittest.TestCase    ):
 @slow
 def 					UpperCAmelCase_							(    self				:Union[str, Any]							)->							int:
     A__    =      DistilBertModel.from_pretrained("distilbert-base-uncased"							)
     A__    =      torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]							)
     A__    =      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]							)
     with torch.no_grad():
         A__    =      model(lowercase_						,	attention_mask=lowercase_							)[0]
     A__    =      torch.Size((1, 11, 7_68)							)
     self.assertEqual(output.shape						,	lowercase_							)
     A__    =      torch.tensor(
         [[[-0.1_6_3_9, 0.3_2_9_9, 0.1_6_4_8], [-0.1_7_4_6, 0.3_2_8_9, 0.1_7_1_0], [-0.1_8_8_4, 0.3_3_5_7, 0.1_8_1_0]]]							)

     self.assertTrue(torch.allclose(output[:, 1:4, 1:4]						,	lowercase_						,	atol=1E-4							)							)










'''simple docstring'''

import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest






class        UpperCAmelCase     (	UpperCamelCase__    ):
 __lowercase       		=    (PNDMScheduler,)
 __lowercase       		=    (("""num_inference_steps""", 50),)
 def 					UpperCAmelCase_							(    self				:List[str]						,	**lowercase_				:Optional[int]							)->							List[str]:
     A__    =      {
         "num_train_timesteps": 10_00,
         "beta_start": 0.0_0_0_1,
         "beta_end": 0.0_2,
         "beta_schedule": "linear",
     }

     config.update(**lowercase_							)
     return config
 def 					UpperCAmelCase_							(    self				:int						,	lowercase_				:Optional[int]=0						,	**lowercase_				:Any							)->							int:
     A__    =      dict(self.forward_default_kwargs							)
     A__    =      kwargs.pop("num_inference_steps"						,	lowercase_							)
     A__    =      self.dummy_sample
     A__    =      0.1 * sample
     A__    =      [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

     for scheduler_class in self.scheduler_classes:
         A__    =      self.get_scheduler_config(**lowercase_							)
         A__    =      scheduler_class(**lowercase_							)
         scheduler.set_timesteps(lowercase_							)
         # copy over dummy past residuals
         A__    =      dummy_past_residuals[:]

         with tempfile.TemporaryDirectory() as tmpdirname:
             scheduler.save_config(lowercase_							)
             A__    =      scheduler_class.from_pretrained(lowercase_							)
             new_scheduler.set_timesteps(lowercase_							)
             # copy over dummy past residuals
             A__    =      dummy_past_residuals[:]

         A__    =      scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      new_scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample

         assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"

         A__    =      scheduler.step_plms(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      new_scheduler.step_plms(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample

         assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"
 def 					UpperCAmelCase_							(    self				:List[Any]							)->							Tuple:
     pass
 def 					UpperCAmelCase_							(    self				:Optional[Any]						,	lowercase_				:Optional[Any]=0						,	**lowercase_				:List[str]							)->							str:
     A__    =      dict(self.forward_default_kwargs							)
     A__    =      kwargs.pop("num_inference_steps"						,	lowercase_							)
     A__    =      self.dummy_sample
     A__    =      0.1 * sample
     A__    =      [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

     for scheduler_class in self.scheduler_classes:
         A__    =      self.get_scheduler_config()
         A__    =      scheduler_class(**lowercase_							)
         scheduler.set_timesteps(lowercase_							)

         # copy over dummy past residuals (must be after setting timesteps)
         A__    =      dummy_past_residuals[:]

         with tempfile.TemporaryDirectory() as tmpdirname:
             scheduler.save_config(lowercase_							)
             A__    =      scheduler_class.from_pretrained(lowercase_							)
             # copy over dummy past residuals
             new_scheduler.set_timesteps(lowercase_							)

             # copy over dummy past residual (must be after setting timesteps)
             A__    =      dummy_past_residuals[:]

         A__    =      scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      new_scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample

         assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"

         A__    =      scheduler.step_plms(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      new_scheduler.step_plms(lowercase_						,	lowercase_						,	lowercase_						,	**lowercase_							).prev_sample

         assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"
 def 					UpperCAmelCase_							(    self				:Optional[int]						,	**lowercase_				:Dict							)->							Optional[int]:
     A__    =      self.scheduler_classes[0]
     A__    =      self.get_scheduler_config(**lowercase_							)
     A__    =      scheduler_class(**lowercase_							)

     A__    =      10
     A__    =      self.dummy_model()
     A__    =      self.dummy_sample_deter
     scheduler.set_timesteps(lowercase_							)

     for i, t in enumerate(scheduler.prk_timesteps							):
         A__    =      model(lowercase_						,	lowercase_							)
         A__    =      scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_							).prev_sample

     for i, t in enumerate(scheduler.plms_timesteps							):
         A__    =      model(lowercase_						,	lowercase_							)
         A__    =      scheduler.step_plms(lowercase_						,	lowercase_						,	lowercase_							).prev_sample

     return sample
 def 					UpperCAmelCase_							(    self				:int							)->							Union[str, Any]:
     A__    =      dict(self.forward_default_kwargs							)

     A__    =      kwargs.pop("num_inference_steps"						,	lowercase_							)

     for scheduler_class in self.scheduler_classes:
         A__    =      self.get_scheduler_config()
         A__    =      scheduler_class(**lowercase_							)

         A__    =      self.dummy_sample
         A__    =      0.1 * sample

         if num_inference_steps is not None and hasattr(lowercase_						,	"set_timesteps"							):
             scheduler.set_timesteps(lowercase_							)
         elif num_inference_steps is not None and not hasattr(lowercase_						,	"set_timesteps"							):
             A__    =      num_inference_steps

         # copy over dummy past residuals (must be done after set_timesteps)
         A__    =      [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]
         A__    =      dummy_past_residuals[:]

         A__    =      scheduler.step_prk(lowercase_						,	0						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      scheduler.step_prk(lowercase_						,	1						,	lowercase_						,	**lowercase_							).prev_sample

         self.assertEqual(output_a.shape						,	sample.shape							)
         self.assertEqual(output_a.shape						,	output_a.shape							)

         A__    =      scheduler.step_plms(lowercase_						,	0						,	lowercase_						,	**lowercase_							).prev_sample
         A__    =      scheduler.step_plms(lowercase_						,	1						,	lowercase_						,	**lowercase_							).prev_sample

         self.assertEqual(output_a.shape						,	sample.shape							)
         self.assertEqual(output_a.shape						,	output_a.shape							)
 def 					UpperCAmelCase_							(    self				:Any							)->							Dict:
     for timesteps in [1_00, 10_00]:
         self.check_over_configs(num_train_timesteps=lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[str]							)->							int:
     for steps_offset in [0, 1]:
         self.check_over_configs(steps_offset=lowercase_							)

     A__    =      self.scheduler_classes[0]
     A__    =      self.get_scheduler_config(steps_offset=1							)
     A__    =      scheduler_class(**lowercase_							)
     scheduler.set_timesteps(10							)
     assert torch.equal(
         scheduler.timesteps						,	torch.LongTensor(
             [9_01, 8_51, 8_51, 8_01, 8_01, 7_51, 7_51, 7_01, 7_01, 6_51, 6_51, 6_01, 6_01, 5_01, 4_01, 3_01, 2_01, 1_01, 1]							)						,	)
 def 					UpperCAmelCase_							(    self				:Optional[Any]							)->							Any:
     for beta_start, beta_end in zip([0.0_0_0_1, 0.0_0_1]						,	[0.0_0_2, 0.0_2]							):
         self.check_over_configs(beta_start=lowercase_						,	beta_end=lowercase_							)
 def 					UpperCAmelCase_							(    self				:Tuple							)->							Tuple:
     for schedule in ["linear", "squaredcos_cap_v2"]:
         self.check_over_configs(beta_schedule=lowercase_							)
 def 					UpperCAmelCase_							(    self				:Optional[Any]							)->							Tuple:
     for prediction_type in ["epsilon", "v_prediction"]:
         self.check_over_configs(prediction_type=lowercase_							)
 def 					UpperCAmelCase_							(    self				:Optional[int]							)->							Tuple:
     for t in [1, 5, 10]:
         self.check_over_forward(time_step=lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[Any]							)->							Optional[int]:
     for t, num_inference_steps in zip([1, 5, 10]						,	[10, 50, 1_00]							):
         self.check_over_forward(num_inference_steps=lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[str]							)->							str:
     # earlier version of set_timesteps() caused an error indexing alpha's with inference steps as power of 3
     A__    =      27

     for scheduler_class in self.scheduler_classes:
         A__    =      self.dummy_sample
         A__    =      0.1 * sample

         A__    =      self.get_scheduler_config()
         A__    =      scheduler_class(**lowercase_							)

         scheduler.set_timesteps(lowercase_							)

         # before power of 3 fix, would error on first step, so we only need to do two
         for i, t in enumerate(scheduler.prk_timesteps[:2]							):
             A__    =      scheduler.step_prk(lowercase_						,	lowercase_						,	lowercase_							).prev_sample
 def 					UpperCAmelCase_							(    self				:List[str]							)->							str:
     with self.assertRaises(lowercase_							):
         A__    =      self.scheduler_classes[0]
         A__    =      self.get_scheduler_config()
         A__    =      scheduler_class(**lowercase_							)

         scheduler.step_plms(self.dummy_sample						,	1						,	self.dummy_sample							).prev_sample
 def 					UpperCAmelCase_							(    self				:int							)->							str:
     A__    =      self.full_loop()
     A__    =      torch.sum(torch.abs(lowercase_							)							)
     A__    =      torch.mean(torch.abs(lowercase_							)							)

     assert abs(result_sum.item() - 1_9_8.1_3_1_8							) < 1E-2
     assert abs(result_mean.item() - 0.2_5_8_0							) < 1E-3
 def 					UpperCAmelCase_							(    self				:Optional[Any]							)->							List[Any]:
     A__    =      self.full_loop(prediction_type="v_prediction"							)
     A__    =      torch.sum(torch.abs(lowercase_							)							)
     A__    =      torch.mean(torch.abs(lowercase_							)							)

     assert abs(result_sum.item() - 6_7.3_9_8_6							) < 1E-2
     assert abs(result_mean.item() - 0.0_8_7_8							) < 1E-3
 def 					UpperCAmelCase_							(    self				:Tuple							)->							Tuple:
     # We specify different beta, so that the first alpha is 0.99
     A__    =      self.full_loop(set_alpha_to_one=lowercase_						,	beta_start=0.0_1							)
     A__    =      torch.sum(torch.abs(lowercase_							)							)
     A__    =      torch.mean(torch.abs(lowercase_							)							)

     assert abs(result_sum.item() - 2_3_0.0_3_9_9							) < 1E-2
     assert abs(result_mean.item() - 0.2_9_9_5							) < 1E-3



 def 					UpperCAmelCase_							(    self				:Dict							)->							Any:
     # We specify different beta, so that the first alpha is 0.99
     A__    =      self.full_loop(set_alpha_to_one=lowercase_						,	beta_start=0.0_1							)
     A__    =      torch.sum(torch.abs(lowercase_							)							)
     A__    =      torch.mean(torch.abs(lowercase_							)							)

     assert abs(result_sum.item() - 1_8_6.9_4_8_2							) < 1E-2
     assert abs(result_mean.item() - 0.2_4_3_4							) < 1E-3



