import unittest

from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


lowerCAmelCase			:							List[Any]     =get_tests_dir("fixtures/test_sentencepiece_no_bos.model")




@require_sentencepiece
@require_tokenizers
class 	__snake_case	( __lowerCAmelCase ,  unittest.TestCase		):





      '''simple docstring'''






      _snake_case    		=       PegasusTokenizer
      _snake_case    		=       PegasusTokenizerFast
      _snake_case    		=       True
      _snake_case    		=       True



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any])				->List[str]:


          """simple docstring"""


          super().setUp()

          # We have a SentencePiece fixture for testing
          _lowerCamelCase     :		List[Any] 						=						PegasusTokenizer(_UpperCamelCase)
          tokenizer.save_pretrained(self.tmpdirname)



      @cached_property
      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->Union[str, Any]:


          """simple docstring"""


          return PegasusTokenizer.from_pretrained("""google/pegasus-large""")



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple    ,  **_UpperCamelCase     :				Tuple)				->PegasusTokenizer:


          """simple docstring"""


          return PegasusTokenizer.from_pretrained(self.tmpdirname    ,  **_UpperCamelCase)



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


          """simple docstring"""


          return ("This is a test", "This is a test")



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any])				->Any:


          """simple docstring"""


          _lowerCamelCase     :		Optional[int] 						=						"""</s>"""
          _lowerCamelCase     :		Dict 						=						1

          self.assertEqual(self.get_tokenizer()._convert_token_to_id(_UpperCamelCase)    ,  _UpperCamelCase)
          self.assertEqual(self.get_tokenizer()._convert_id_to_token(_UpperCamelCase)    ,  _UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->int:


          """simple docstring"""


          _lowerCamelCase     :		Dict 						=						list(self.get_tokenizer().get_vocab().keys())

          self.assertEqual(vocab_keys[0]    ,  """<pad>""")
          self.assertEqual(vocab_keys[1]    ,  """</s>""")
          self.assertEqual(vocab_keys[-1]    ,  """v""")
          self.assertEqual(len(_UpperCamelCase)    ,  1103)



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


          """simple docstring"""


          self.assertEqual(self.get_tokenizer().vocab_size    ,  1103)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->Dict:


          """simple docstring"""


          _lowerCamelCase     :		str 						=						self.rust_tokenizer_class.from_pretrained(self.tmpdirname)
          _lowerCamelCase     :		Tuple 						=						self.tokenizer_class.from_pretrained(self.tmpdirname)
          _lowerCamelCase     :		Optional[int] 						=						(
              """Let's see which <unk> is the better <unk_token_11> one <mask_1> It seems like this <mask_2> was important"""
              """ </s> <pad> <pad> <pad>"""
          )
          _lowerCamelCase     :		List[Any] 						=						rust_tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase    ,  add_special_tokens=_UpperCamelCase).input_ids[0]
          _lowerCamelCase     :		List[Any] 						=						py_tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase    ,  add_special_tokens=_UpperCamelCase).input_ids[0]
          self.assertListEqual(_UpperCamelCase    ,  _UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->Optional[Any]:


          """simple docstring"""


          _lowerCamelCase     :		List[Any] 						=						self._large_tokenizer
          # <mask_1> masks whole sentence while <mask_2> masks single word
          _lowerCamelCase     :		str 						=						"""<mask_1> To ensure a <mask_2> flow of bank resolutions."""
          _lowerCamelCase     :		Optional[int] 						=						[2, 413, 615, 114, 3, 1971, 113, 1679, 1_0710, 107, 1]
          _lowerCamelCase     :		List[Any] 						=						tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase).input_ids[0]
          self.assertListEqual(_UpperCamelCase    ,  _UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->Any:


          """simple docstring"""


          _lowerCamelCase     :		int 						=						self._large_tokenizer
          # The tracebacks for the following asserts are **better** without messages or self.assertEqual
          assert tokenizer.vocab_size == 9_6103
          assert tokenizer.pad_token_id == 0
          assert tokenizer.eos_token_id == 1
          assert tokenizer.offset == 103
          assert tokenizer.unk_token_id == tokenizer.offset + 2 == 105
          assert tokenizer.unk_token == "<unk>"
          assert tokenizer.model_max_length == 1024
          _lowerCamelCase     :		Any 						=						"""To ensure a smooth flow of bank resolutions."""
          _lowerCamelCase     :		Optional[int] 						=						[413, 615, 114, 2291, 1971, 113, 1679, 1_0710, 107, 1]
          _lowerCamelCase     :		Any 						=						tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase).input_ids[0]
          self.assertListEqual(_UpperCamelCase    ,  _UpperCamelCase)
          assert tokenizer.convert_ids_to_tokens([0, 1, 2, 3]) == ["<pad>", "</s>", "<mask_1>", "<mask_2>"]



      @require_torch
      def 	_SCREAMING_SNAKE_CASE    (					self     :				Dict)				->int:


          """simple docstring"""


          _lowerCamelCase     :		Optional[int] 						=						["""This is going to be way too long.""" * 150, """short example"""]
          _lowerCamelCase     :		Dict 						=						["""not super long but more than 5 tokens""", """tiny"""]
          _lowerCamelCase     :		List[Any] 						=						self._large_tokenizer(_UpperCamelCase    ,  padding=_UpperCamelCase    ,  truncation=_UpperCamelCase    ,  return_tensors="""pt""")
          _lowerCamelCase     :		int 						=						self._large_tokenizer(
              text_target=_UpperCamelCase    ,  max_length=5    ,  padding=_UpperCamelCase    ,  truncation=_UpperCamelCase    ,  return_tensors="""pt""")

          assert batch.input_ids.shape == (2, 1024)
          assert batch.attention_mask.shape == (2, 1024)
          assert targets["input_ids"].shape == (2, 5)
          assert len(_UpperCamelCase) == 2  # input_ids, attention_mask.




      @slow
      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->str:


          """simple docstring"""


          _lowerCamelCase     :		List[str] 						=						{"""input_ids""": [[3_8979, 143, 1_8485, 606, 130, 2_6669, 8_7686, 121, 5_4189, 1129, 111, 2_6669, 8_7686, 121, 9114, 1_4787, 121, 1_3249, 158, 592, 956, 121, 1_4621, 3_1576, 143, 6_2613, 108, 9688, 930, 4_3430, 1_1562, 6_2613, 304, 108, 1_1443, 897, 108, 9314, 1_7415, 6_3399, 108, 1_1443, 7614, 1_8316, 118, 4284, 7148, 1_2430, 143, 1400, 2_5703, 158, 111, 4284, 7148, 1_1772, 143, 2_1297, 1064, 158, 122, 204, 3506, 1754, 1133, 1_4787, 1581, 115, 3_3224, 4482, 111, 1355, 110, 2_9173, 317, 5_0833, 108, 2_0147, 9_4665, 111, 7_7198, 107, 1], [110, 6_2613, 117, 638, 112, 1133, 121, 2_0098, 1355, 7_9050, 1_3872, 135, 1596, 5_3541, 1352, 141, 1_3039, 5542, 124, 302, 518, 111, 268, 2956, 115, 149, 4427, 107, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [139, 1235, 2799, 1_8289, 1_7780, 204, 109, 9474, 1296, 107, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], """attention_mask""": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
          # fmt: on

          self.tokenizer_integration_test_util(
              expected_encoding=_UpperCamelCase    ,  model_name="""google/bigbird-pegasus-large-arxiv"""    ,  revision="""ba85d0851d708441f91440d509690f1ab6353415"""    ,  )





@require_sentencepiece
@require_tokenizers
class 	__snake_case	( __lowerCAmelCase ,  unittest.TestCase		):





      '''simple docstring'''






      _snake_case    		=       PegasusTokenizer
      _snake_case    		=       PegasusTokenizerFast
      _snake_case    		=       True
      _snake_case    		=       True



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->Tuple:


          """simple docstring"""


          super().setUp()

          # We have a SentencePiece fixture for testing
          _lowerCamelCase     :		Union[str, Any] 						=						PegasusTokenizer(_UpperCamelCase    ,  offset=0    ,  mask_token_sent=_UpperCamelCase    ,  mask_token="""[MASK]""")
          tokenizer.save_pretrained(self.tmpdirname)



      @cached_property
      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->Optional[Any]:


          """simple docstring"""


          return PegasusTokenizer.from_pretrained("""google/bigbird-pegasus-large-arxiv""")



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[str]    ,  **_UpperCamelCase     :				List[Any])				->PegasusTokenizer:


          """simple docstring"""


          return PegasusTokenizer.from_pretrained(self.tmpdirname    ,  **_UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				int    ,  _UpperCamelCase     :				Dict)				->List[Any]:


          """simple docstring"""


          return ("This is a test", "This is a test")



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Dict)				->Dict:


          """simple docstring"""


          _lowerCamelCase     :		Any 						=						self.rust_tokenizer_class.from_pretrained(self.tmpdirname)
          _lowerCamelCase     :		List[str] 						=						self.tokenizer_class.from_pretrained(self.tmpdirname)
          _lowerCamelCase     :		int 						=						(
              """Let's see which <unk> is the better <unk_token> one [MASK] It seems like this [MASK] was important </s>"""
              """ <pad> <pad> <pad>"""
          )
          _lowerCamelCase     :		Union[str, Any] 						=						rust_tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase    ,  add_special_tokens=_UpperCamelCase).input_ids[0]
          _lowerCamelCase     :		str 						=						py_tokenizer([raw_input_str]    ,  return_tensors=_UpperCamelCase    ,  add_special_tokens=_UpperCamelCase).input_ids[0]
          self.assertListEqual(_UpperCamelCase    ,  _UpperCamelCase)



      @require_torch
      def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[Any])				->int:


          """simple docstring"""


          _lowerCamelCase     :		List[Any] 						=						["""This is going to be way too long.""" * 1000, """short example"""]
          _lowerCamelCase     :		Tuple 						=						["""not super long but more than 5 tokens""", """tiny"""]
          _lowerCamelCase     :		Optional[int] 						=						self._large_tokenizer(_UpperCamelCase    ,  padding=_UpperCamelCase    ,  truncation=_UpperCamelCase    ,  return_tensors="""pt""")
          _lowerCamelCase     :		List[str] 						=						self._large_tokenizer(
              text_target=_UpperCamelCase    ,  max_length=5    ,  padding=_UpperCamelCase    ,  truncation=_UpperCamelCase    ,  return_tensors="""pt""")

          assert batch.input_ids.shape == (2, 4096)
          assert batch.attention_mask.shape == (2, 4096)
          assert targets["input_ids"].shape == (2, 5)
          assert len(_UpperCamelCase) == 2  # input_ids, attention_mask.




      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple)				->str:


          """simple docstring"""


          _lowerCamelCase     :		Tuple 						=						(
              """This is an example string that is used to test the original TF implementation against the HF"""
              """ implementation"""
          )

          _lowerCamelCase     :		int 						=						self._large_tokenizer(_UpperCamelCase).input_ids

          self.assertListEqual(
              _UpperCamelCase    ,  [182, 117, 142, 587, 4211, 120, 117, 263, 112, 804, 109, 856, 2_5016, 3137, 464, 109, 2_6955, 3137, 1]    ,  )





import torch

from diffusers import EulerDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest




class 	__snake_case	( __lowerCAmelCase		):





      '''simple docstring'''






      _snake_case    		=       (EulerDiscreteScheduler,)
      _snake_case    		=       10



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Tuple    ,  **_UpperCamelCase     :				Optional[Any])				->Optional[Any]:


          """simple docstring"""


          _lowerCamelCase     :		Optional[int] 						=						{
              """num_train_timesteps""": 1100,
              """beta_start""": 0.0_0_0_1,
              """beta_end""": 0.0_2,
              """beta_schedule""": """linear""",
          }

          config.update(**_UpperCamelCase)
          return config



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


          """simple docstring"""


          for timesteps in [10, 50, 100, 1000]:
              self.check_over_configs(num_train_timesteps=_UpperCamelCase)



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


          """simple docstring"""


          for beta_start, beta_end in zip([0.0_0_0_0_1, 0.0_0_0_1, 0.0_0_1]    ,  [0.0_0_0_2, 0.0_0_2, 0.0_2]):
              self.check_over_configs(beta_start=_UpperCamelCase    ,  beta_end=_UpperCamelCase)



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Any)				->Dict:


          """simple docstring"""


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



      def 	_SCREAMING_SNAKE_CASE    (					self     :				Optional[int])				->Union[str, Any]:


          """simple docstring"""


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



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


          """simple docstring"""


          _lowerCamelCase     :		List[Any] 						=						self.scheduler_classes[0]
          _lowerCamelCase     :		str 						=						self.get_scheduler_config()
          _lowerCamelCase     :		Any 						=						scheduler_class(**_UpperCamelCase)

          scheduler.set_timesteps(self.num_inference_steps)

          _lowerCamelCase     :		str 						=						torch.manual_seed(0)

          _lowerCamelCase     :		str 						=						self.dummy_model()
          _lowerCamelCase     :		List[Any] 						=						self.dummy_sample_deter * scheduler.init_noise_sigma
          _lowerCamelCase     :		int 						=						sample.to(_UpperCamelCase)

          for i, t in enumerate(scheduler.timesteps):
              _lowerCamelCase     :		Optional[int] 						=						scheduler.scale_model_input(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		List[str] 						=						model(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		str 						=						scheduler.step(_UpperCamelCase    ,  _UpperCamelCase    ,  _UpperCamelCase    ,  generator=_UpperCamelCase)
              _lowerCamelCase     :		Dict 						=						output.prev_sample

          _lowerCamelCase     :		Any 						=						torch.sum(torch.abs(_UpperCamelCase))
          _lowerCamelCase     :		Any 						=						torch.mean(torch.abs(_UpperCamelCase))

          assert abs(result_sum.item() - 1_0.0_8_0_7) < 1E-2
          assert abs(result_mean.item() - 0.0_1_3_1) < 1E-3



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


          """simple docstring"""


          _lowerCamelCase     :		int 						=						self.scheduler_classes[0]
          _lowerCamelCase     :		Optional[Any] 						=						self.get_scheduler_config(prediction_type="""v_prediction""")
          _lowerCamelCase     :		int 						=						scheduler_class(**_UpperCamelCase)

          scheduler.set_timesteps(self.num_inference_steps)

          _lowerCamelCase     :		Any 						=						torch.manual_seed(0)

          _lowerCamelCase     :		int 						=						self.dummy_model()
          _lowerCamelCase     :		int 						=						self.dummy_sample_deter * scheduler.init_noise_sigma
          _lowerCamelCase     :		Dict 						=						sample.to(_UpperCamelCase)

          for i, t in enumerate(scheduler.timesteps):
              _lowerCamelCase     :		Optional[int] 						=						scheduler.scale_model_input(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		str 						=						model(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		List[Any] 						=						scheduler.step(_UpperCamelCase    ,  _UpperCamelCase    ,  _UpperCamelCase    ,  generator=_UpperCamelCase)
              _lowerCamelCase     :		Tuple 						=						output.prev_sample

          _lowerCamelCase     :		Union[str, Any] 						=						torch.sum(torch.abs(_UpperCamelCase))
          _lowerCamelCase     :		Optional[int] 						=						torch.mean(torch.abs(_UpperCamelCase))

          assert abs(result_sum.item() - 0.0_0_0_2) < 1E-2
          assert abs(result_mean.item() - 2.2_6_7_6E-0_6) < 1E-3



      def 	_SCREAMING_SNAKE_CASE    (					self     :				List[Any])				->List[Any]:


          """simple docstring"""


          _lowerCamelCase     :		Union[str, Any] 						=						self.scheduler_classes[0]
          _lowerCamelCase     :		int 						=						self.get_scheduler_config()
          _lowerCamelCase     :		List[Any] 						=						scheduler_class(**_UpperCamelCase)

          scheduler.set_timesteps(self.num_inference_steps    ,  device=_UpperCamelCase)

          _lowerCamelCase     :		Optional[Any] 						=						torch.manual_seed(0)

          _lowerCamelCase     :		Tuple 						=						self.dummy_model()
          _lowerCamelCase     :		Optional[Any] 						=						self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
          _lowerCamelCase     :		Tuple 						=						sample.to(_UpperCamelCase)

          for t in scheduler.timesteps:
              _lowerCamelCase     :		List[Any] 						=						scheduler.scale_model_input(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		List[str] 						=						model(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		Any 						=						scheduler.step(_UpperCamelCase    ,  _UpperCamelCase    ,  _UpperCamelCase    ,  generator=_UpperCamelCase)
              _lowerCamelCase     :		List[Any] 						=						output.prev_sample

          _lowerCamelCase     :		Any 						=						torch.sum(torch.abs(_UpperCamelCase))
          _lowerCamelCase     :		List[Any] 						=						torch.mean(torch.abs(_UpperCamelCase))

          assert abs(result_sum.item() - 1_0.0_8_0_7) < 1E-2
          assert abs(result_mean.item() - 0.0_1_3_1) < 1E-3




      def 	_SCREAMING_SNAKE_CASE    (					self     :				int)				->Tuple:


          """simple docstring"""


          _lowerCamelCase     :		List[str] 						=						self.scheduler_classes[0]
          _lowerCamelCase     :		Optional[int] 						=						self.get_scheduler_config()
          _lowerCamelCase     :		int 						=						scheduler_class(**_UpperCamelCase    ,  use_karras_sigmas=_UpperCamelCase)

          scheduler.set_timesteps(self.num_inference_steps    ,  device=_UpperCamelCase)

          _lowerCamelCase     :		int 						=						torch.manual_seed(0)

          _lowerCamelCase     :		Tuple 						=						self.dummy_model()
          _lowerCamelCase     :		str 						=						self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
          _lowerCamelCase     :		Optional[int] 						=						sample.to(_UpperCamelCase)

          for t in scheduler.timesteps:
              _lowerCamelCase     :		Tuple 						=						scheduler.scale_model_input(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		Any 						=						model(_UpperCamelCase    ,  _UpperCamelCase)

              _lowerCamelCase     :		List[str] 						=						scheduler.step(_UpperCamelCase    ,  _UpperCamelCase    ,  _UpperCamelCase    ,  generator=_UpperCamelCase)
              _lowerCamelCase     :		int 						=						output.prev_sample

          _lowerCamelCase     :		Tuple 						=						torch.sum(torch.abs(_UpperCamelCase))
          _lowerCamelCase     :		List[str] 						=						torch.mean(torch.abs(_UpperCamelCase))

          assert abs(result_sum.item() - 1_2_4.5_2_2_9_9_4_9_9_5_1_1_7_1_9) < 1E-2
          assert abs(result_mean.item() - 0.1_6_2_1_3_9_3_2_6_3_3_3_9_9_9_6_3) < 1E-3




