
import os
import pickle
import tempfile
import unittest
from typing import Callable, Optional

import numpy as np

from transformers import (
    BatchEncoding,
    BertTokenizer,
    BertTokenizerFast,
    PreTrainedTokenizer,
    PreTrainedTokenizerFast,
    TensorType,
    TokenSpan,
    is_tokenizers_available,
)
from transformers.models.gpta.tokenization_gpta import GPTaTokenizer
from transformers.testing_utils import CaptureStderr, require_flax, require_tf, require_tokenizers, require_torch, slow


if is_tokenizers_available():
   from tokenizers import Tokenizer
   from tokenizers.models import WordPiece

class 						UpperCAmelCase__   (      unittest.TestCase		):



     '''simple docstring'''




     def   lowerCAmelCase_   ( self       :       Tuple	,      UpperCamelCase       :       List[str]		):





            """simple docstring"""



            _lowercase					:				int           =			list(tokenizer_class.max_model_input_sizes.keys()		)
            for model_name in sa_models[:1]:
                   _lowercase					:				Tuple           =			tokenizer_class.from_pretrained(UpperCamelCase_		)
                   self.assertIsNotNone(UpperCamelCase_		)
                   self.assertIsInstance(UpperCamelCase_	,      UpperCamelCase_		)
                   self.assertIsInstance(UpperCamelCase_	,      UpperCamelCase_		)

                   for special_tok in tokenizer.all_special_tokens:
                          self.assertIsInstance(UpperCamelCase_	,      UpperCamelCase_		)
                          _lowercase					:				List[str]           =			tokenizer.convert_tokens_to_ids(UpperCamelCase_		)
                          self.assertIsInstance(UpperCamelCase_	,      UpperCamelCase_		)




     def   lowerCAmelCase_   ( self       :       int	,      UpperCamelCase       :       BatchEncoding	,      UpperCamelCase       :       Optional[Callable] = None		):





            """simple docstring"""



            _lowercase					:				Any           =			pickle.dumps(UpperCamelCase_		)
            self.assertIsNotNone(UpperCamelCase_		)

            _lowercase					:				Any           =			pickle.loads(UpperCamelCase_		)

            # Ensure is_fast is correctly restored
            self.assertEqual(be_restored.is_fast	,      be_original.is_fast		)

            # Ensure encodings are potentially correctly restored
            if be_original.is_fast:
                   self.assertIsNotNone(be_restored.encodings		)
            else:
                   self.assertIsNone(be_restored.encodings		)

            # Ensure the keys are the same
            for original_v, restored_v in zip(be_original.values()	,      be_restored.values()		):
                   if equal_op:
                          self.assertTrue(equal_op(UpperCamelCase_	,      UpperCamelCase_		)		)
                   else:
                          self.assertEqual(UpperCamelCase_	,      UpperCamelCase_		)




     @slow
     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            self.check_tokenizer_from_pretrained(UpperCamelCase_		)




     def   lowerCAmelCase_   ( self       :       Optional[Any]		):





            """simple docstring"""



            self.assertEqual(TensorType('''tf'''		)	,      TensorType.TENSORFLOW		)
            self.assertEqual(TensorType('''pt'''		)	,      TensorType.PYTORCH		)
            self.assertEqual(TensorType('''np'''		)	,      TensorType.NUMPY		)




     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Tuple		):





            """simple docstring"""



            import numpy as np

            _lowercase					:				List[str]           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)
            _lowercase					:				Dict           =			BertTokenizerFast.from_pretrained('''bert-base-cased'''		)

            # Python no tensor
            with self.subTest('''BatchEncoding (Python, return_tensors=None)'''		):
                   self.assert_dump_and_restore(tokenizer_p('''Small example to encode'''		)		)

            with self.subTest('''BatchEncoding (Python, return_tensors=NUMPY)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_p('''Small example to encode'''	,      return_tensors=TensorType.NUMPY		)	,      np.array_equal		)

            with self.subTest('''BatchEncoding (Rust, return_tensors=None)'''		):
                   self.assert_dump_and_restore(tokenizer_r('''Small example to encode'''		)		)

            with self.subTest('''BatchEncoding (Rust, return_tensors=NUMPY)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_r('''Small example to encode'''	,      return_tensors=TensorType.NUMPY		)	,      np.array_equal		)




     @require_tf
     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Dict		):





            """simple docstring"""



            import tensorflow as tf

            def tf_array_equals(UpperCamelCase       :       List[str]	,      UpperCamelCase       :       Optional[int]		):
                   return tf.reduce_all(tf.equal(UpperCamelCase_	,      UpperCamelCase_		)		)

            _lowercase					:				Dict           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)
            _lowercase					:				str           =			BertTokenizerFast.from_pretrained('''bert-base-cased'''		)

            with self.subTest('''BatchEncoding (Python, return_tensors=TENSORFLOW)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_p('''Small example to encode'''	,      return_tensors=TensorType.TENSORFLOW		)	,      UpperCamelCase_		)

            with self.subTest('''BatchEncoding (Rust, return_tensors=TENSORFLOW)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_r('''Small example to encode'''	,      return_tensors=TensorType.TENSORFLOW		)	,      UpperCamelCase_		)




     @require_torch
     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       List[Any]		):





            """simple docstring"""



            import torch

            _lowercase					:				Union[str, Any]           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)
            _lowercase					:				List[str]           =			BertTokenizerFast.from_pretrained('''bert-base-cased'''		)

            with self.subTest('''BatchEncoding (Python, return_tensors=PYTORCH)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_p('''Small example to encode'''	,      return_tensors=TensorType.PYTORCH		)	,      torch.equal		)

            with self.subTest('''BatchEncoding (Rust, return_tensors=PYTORCH)'''		):
                   self.assert_dump_and_restore(
                       tokenizer_r('''Small example to encode'''	,      return_tensors=TensorType.PYTORCH		)	,      torch.equal		)




     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Optional[int]		):





            """simple docstring"""



            _lowercase					:				Optional[int]           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)
            _lowercase					:				List[str]           =			BertTokenizerFast.from_pretrained('''bert-base-cased'''		)

            with self.subTest('''Python Tokenizer'''		):
                   self.assertFalse(tokenizer_p('''Small example to_encode'''		).is_fast		)

            with self.subTest('''Rust Tokenizer'''		):
                   self.assertTrue(tokenizer_r('''Small example to_encode'''		).is_fast		)




     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Optional[int]		):





            """simple docstring"""



            _lowercase					:				List[str]           =			BertTokenizerFast.from_pretrained('''bert-base-cased'''		)
            _lowercase					:				Tuple           =			tokenizer_r(['''Test''', '''\xad''', '''test''']	,      is_split_into_words=UpperCamelCase_		)

            self.assertEqual(encoded.word_to_tokens(0		)	,      TokenSpan(start=1	,      end=2		)		)
            self.assertEqual(encoded.word_to_tokens(1		)	,      UpperCamelCase_		)
            self.assertEqual(encoded.word_to_tokens(2		)	,      TokenSpan(start=2	,      end=3		)		)




     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            _lowercase					:				Tuple           =			BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}		)
            _lowercase					:				Optional[int]           =			batch.convert_to_tensors(tensor_type='''np'''		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (2, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (2,)		)
            # test converting the converted
            with CaptureStderr() as cs:
                   _lowercase					:				Optional[Any]           =			batch.convert_to_tensors(tensor_type='''np'''		)
            self.assertFalse(len(cs.err		)	,      msg=F'should have no warning, but got {cs.err}'		)

            _lowercase					:				int           =			BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}		)
            _lowercase					:				str           =			batch.convert_to_tensors(tensor_type='''np'''	,      prepend_batch_axis=UpperCamelCase_		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (1, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (1,)		)




     @require_torch
     def   lowerCAmelCase_   ( self       :       Dict		):





            """simple docstring"""



            _lowercase					:				str           =			BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}		)
            _lowercase					:				List[str]           =			batch.convert_to_tensors(tensor_type='''pt'''		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (2, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (2,)		)
            # test converting the converted
            with CaptureStderr() as cs:
                   _lowercase					:				Tuple           =			batch.convert_to_tensors(tensor_type='''pt'''		)
            self.assertFalse(len(cs.err		)	,      msg=F'should have no warning, but got {cs.err}'		)

            _lowercase					:				str           =			BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}		)
            _lowercase					:				Union[str, Any]           =			batch.convert_to_tensors(tensor_type='''pt'''	,      prepend_batch_axis=UpperCamelCase_		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (1, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (1,)		)




     @require_tf
     def   lowerCAmelCase_   ( self       :       Dict		):





            """simple docstring"""



            _lowercase					:				Union[str, Any]           =			BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}		)
            _lowercase					:				List[Any]           =			batch.convert_to_tensors(tensor_type='''tf'''		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (2, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (2,)		)
            # test converting the converted
            with CaptureStderr() as cs:
                   _lowercase					:				Optional[Any]           =			batch.convert_to_tensors(tensor_type='''tf'''		)
            self.assertFalse(len(cs.err		)	,      msg=F'should have no warning, but got {cs.err}'		)

            _lowercase					:				int           =			BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}		)
            _lowercase					:				List[str]           =			batch.convert_to_tensors(tensor_type='''tf'''	,      prepend_batch_axis=UpperCamelCase_		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (1, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (1,)		)




     @require_flax
     def   lowerCAmelCase_   ( self       :       Union[str, Any]		):





            """simple docstring"""



            _lowercase					:				Any           =			BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}		)
            _lowercase					:				Tuple           =			batch.convert_to_tensors(tensor_type='''jax'''		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (2, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (2,)		)
            # test converting the converted
            with CaptureStderr() as cs:
                   _lowercase					:				Optional[Any]           =			batch.convert_to_tensors(tensor_type='''jax'''		)
            self.assertFalse(len(cs.err		)	,      msg=F'should have no warning, but got {cs.err}'		)

            _lowercase					:				List[str]           =			BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}		)
            _lowercase					:				Dict           =			batch.convert_to_tensors(tensor_type='''jax'''	,      prepend_batch_axis=UpperCamelCase_		)
            self.assertEqual(tensor_batch['''inputs'''].shape	,      (1, 3)		)
            self.assertEqual(tensor_batch['''labels'''].shape	,      (1,)		)




     def   lowerCAmelCase_   ( self       :       Union[str, Any]		):





            """simple docstring"""



            _lowercase					:				List[Any]           =			[{'''input_ids''': np.array([0, 1, 2]		)}, {'''input_ids''': np.array([0, 1, 2, 3]		)}]
            _lowercase					:				int           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)

            _lowercase					:				Any           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      np.ndarray		)		)
            self.assertEqual(batch['''input_ids'''].tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)
            _lowercase					:				Union[str, Any]           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_	,      return_tensors='''np'''		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      np.ndarray		)		)
            self.assertEqual(batch['''input_ids'''].tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)




     @require_torch
     def   lowerCAmelCase_   ( self       :       int		):





            """simple docstring"""



            import torch

            _lowercase					:				List[str]           =			[{'''input_ids''': torch.tensor([0, 1, 2]		)}, {'''input_ids''': torch.tensor([0, 1, 2, 3]		)}]
            _lowercase					:				List[Any]           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)

            _lowercase					:				Optional[int]           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      torch.Tensor		)		)
            self.assertEqual(batch['''input_ids'''].tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)
            _lowercase					:				str           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_	,      return_tensors='''pt'''		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      torch.Tensor		)		)
            self.assertEqual(batch['''input_ids'''].tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)




     @require_tf
     def   lowerCAmelCase_   ( self       :       List[Any]		):





            """simple docstring"""



            import tensorflow as tf

            _lowercase					:				Union[str, Any]           =			[{'''input_ids''': tf.constant([0, 1, 2]		)}, {'''input_ids''': tf.constant([0, 1, 2, 3]		)}]
            _lowercase					:				int           =			BertTokenizer.from_pretrained('''bert-base-cased'''		)

            _lowercase					:				Optional[Any]           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      tf.Tensor		)		)
            self.assertEqual(batch['''input_ids'''].numpy().tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)
            _lowercase					:				Tuple           =			tokenizer.pad(UpperCamelCase_	,      padding=UpperCamelCase_	,      return_tensors='''tf'''		)
            self.assertTrue(isinstance(batch['''input_ids''']	,      tf.Tensor		)		)
            self.assertEqual(batch['''input_ids'''].numpy().tolist()	,      [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]		)




     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Dict		):





            """simple docstring"""



            _lowercase					:				Dict           =			Tokenizer(WordPiece(unk_token='''[UNK]'''		)		)
            PreTrainedTokenizerFast(tokenizer_object=UpperCamelCase_		)




     @require_tokenizers
     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            _lowercase					:				str           =			Tokenizer(WordPiece(unk_token='''[UNK]'''		)		)
            with tempfile.TemporaryDirectory() as tmpdirname:
                   bert_tokenizer.save(os.path.join(UpperCamelCase_	,      '''tokenizer.json'''		)		)
                   PreTrainedTokenizerFast(tokenizer_file=os.path.join(UpperCamelCase_	,      '''tokenizer.json'''		)		)



import torch

from diffusers import DDIMScheduler

from .test_schedulers import SchedulerCommonTest

class 						UpperCAmelCase__   (      A_		):



     '''simple docstring'''
     UpperCAmelCase_         =  (DDIMScheduler,)
     UpperCAmelCase_         =  (('''eta''', 0.0), ('''num_inference_steps''', 5_0))




     def   lowerCAmelCase_   ( self       :       List[Any]	,      **UpperCamelCase       :       str		):





            """simple docstring"""



            _lowercase					:				Any           =			{
                '''num_train_timesteps''': 10_00,
                '''beta_start''': 0.0001,
                '''beta_end''': 0.02,
                '''beta_schedule''': '''linear''',
                '''clip_sample''': True,
            }

            config.update(**UpperCamelCase		)
            return config




     def   lowerCAmelCase_   ( self       :       str	,      **UpperCamelCase       :       int		):





            """simple docstring"""



            _lowercase					:				str           =			self.scheduler_classes[0]
            _lowercase					:				Dict           =			self.get_scheduler_config(**UpperCamelCase		)
            _lowercase					:				List[str]           =			scheduler_class(**UpperCamelCase		)

            _lowercase       ,	_lowercase					:				int           =			10, 0.0

            _lowercase					:				List[str]           =			self.dummy_model()
            _lowercase					:				int           =			self.dummy_sample_deter

            scheduler.set_timesteps(UpperCamelCase		)

            for t in scheduler.timesteps:
                   _lowercase					:				Union[str, Any]           =			model(UpperCamelCase	,      UpperCamelCase		)
                   _lowercase					:				List[Any]           =			scheduler.step(UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase		).prev_sample

            return sample




     def   lowerCAmelCase_   ( self       :       Dict		):





            """simple docstring"""



            for timesteps in [1_00, 5_00, 10_00]:
                   self.check_over_configs(num_train_timesteps=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       List[Any]		):





            """simple docstring"""



            for steps_offset in [0, 1]:
                   self.check_over_configs(steps_offset=UpperCamelCase		)

            _lowercase					:				List[Any]           =			self.scheduler_classes[0]
            _lowercase					:				Tuple           =			self.get_scheduler_config(steps_offset=1		)
            _lowercase					:				Union[str, Any]           =			scheduler_class(**UpperCamelCase		)
            scheduler.set_timesteps(5		)
            assert torch.equal(scheduler.timesteps	,      torch.LongTensor([8_01, 6_01, 4_01, 2_01, 1]		)		)




     def   lowerCAmelCase_   ( self       :       Optional[Any]		):





            """simple docstring"""



            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   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            for schedule in ["linear", "squaredcos_cap_v2"]:
                   self.check_over_configs(beta_schedule=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Optional[int]		):





            """simple docstring"""



            for prediction_type in ["epsilon", "v_prediction"]:
                   self.check_over_configs(prediction_type=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Optional[Any]		):





            """simple docstring"""



            for clip_sample in [True, False]:
                   self.check_over_configs(clip_sample=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            for timestep_spacing in ["trailing", "leading"]:
                   self.check_over_configs(timestep_spacing=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       List[str]		):





            """simple docstring"""



            for rescale_betas_zero_snr in [True, False]:
                   self.check_over_configs(rescale_betas_zero_snr=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Optional[Any]		):





            """simple docstring"""



            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   lowerCAmelCase_   ( self       :       str		):





            """simple docstring"""



            for t in [1, 10, 49]:
                   self.check_over_forward(time_step=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Optional[int]		):





            """simple docstring"""



            for t, num_inference_steps in zip([1, 10, 50]	,      [10, 50, 5_00]		):
                   self.check_over_forward(time_step=UpperCamelCase	,      num_inference_steps=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       Optional[Any]		):





            """simple docstring"""



            for t, eta in zip([1, 10, 49]	,      [0.0, 0.5, 1.0]		):
                   self.check_over_forward(time_step=UpperCamelCase	,      eta=UpperCamelCase		)




     def   lowerCAmelCase_   ( self       :       List[Any]		):





            """simple docstring"""



            _lowercase					:				int           =			self.scheduler_classes[0]
            _lowercase					:				str           =			self.get_scheduler_config()
            _lowercase					:				int           =			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(4_20	,      4_00		) - 0.14771		)		) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(9_80	,      9_60		) - 0.32460		)		) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(0	,      0		) - 0.0		)		) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(4_87	,      4_86		) - 0.00979		)		) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(9_99	,      9_98		) - 0.02		)		) < 1E-5




     def   lowerCAmelCase_   ( self       :       List[Any]		):





            """simple docstring"""



            _lowercase					:				Any           =			self.full_loop()

            _lowercase					:				Optional[Any]           =			torch.sum(torch.abs(UpperCamelCase		)		)
            _lowercase					:				Union[str, Any]           =			torch.mean(torch.abs(UpperCamelCase		)		)

            assert abs(result_sum.item() - 172.0067		) < 1E-2
            assert abs(result_mean.item() - 0.223967		) < 1E-3




     def   lowerCAmelCase_   ( self       :       Union[str, Any]		):





            """simple docstring"""



            _lowercase					:				List[Any]           =			self.full_loop(prediction_type='''v_prediction'''		)

            _lowercase					:				int           =			torch.sum(torch.abs(UpperCamelCase		)		)
            _lowercase					:				Union[str, Any]           =			torch.mean(torch.abs(UpperCamelCase		)		)

            assert abs(result_sum.item() - 52.5302		) < 1E-2
            assert abs(result_mean.item() - 0.0684		) < 1E-3




     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            _lowercase					:				Tuple           =			self.full_loop(set_alpha_to_one=UpperCamelCase	,      beta_start=0.01		)
            _lowercase					:				List[Any]           =			torch.sum(torch.abs(UpperCamelCase		)		)
            _lowercase					:				Any           =			torch.mean(torch.abs(UpperCamelCase		)		)

            assert abs(result_sum.item() - 149.8295		) < 1E-2
            assert abs(result_mean.item() - 0.1951		) < 1E-3




     def   lowerCAmelCase_   ( self       :       Any		):





            """simple docstring"""



            _lowercase					:				int           =			self.full_loop(set_alpha_to_one=UpperCamelCase	,      beta_start=0.01		)
            _lowercase					:				Optional[int]           =			torch.sum(torch.abs(UpperCamelCase		)		)
            _lowercase					:				Dict           =			torch.mean(torch.abs(UpperCamelCase		)		)

            assert abs(result_sum.item() - 149.0784		) < 1E-2
            assert abs(result_mean.item() - 0.1941		) < 1E-3