
'''simple docstring'''



import argparse
import glob
import inspect
import os
import re
import unittest

from get_test_info import get_test_classes

from tests.test_pipeline_mixin import pipeline_test_mapping


UpperCamelCase__ :						int    							=					{}
for task, _ in pipeline_test_mapping.items():
     UpperCamelCase__ :						List[Any]    							=					{"pt": None, "tf": None}


# DO **NOT** add item to this set (unless the reason is approved)
UpperCamelCase__ :						Union[str, Any]    							=					{
    "tests/models/esm/test_modeling_esmfold.py",  # The pipeline test mapping is added to `test_modeling_esm.py`
}
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       Any:




   """simple docstring"""

   if "ModelTesterMixin" in [x.__name__ for x in test_class.__bases__]:
      return "pt"
   elif "TFModelTesterMixin" in [x.__name__ for x in test_class.__bases__]:
      return "tf"
   elif "FlaxModelTesterMixin" in [x.__name__ for x in test_class.__bases__]:
      return "flax"
   else:
      return None
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )       ->       int:




   """simple docstring"""
   # Use the cached results
   if PIPELINE_TEST_MAPPING[task].get(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  ) is not None:
      return PIPELINE_TEST_MAPPING[task][framework]

   _SCREAMING_SNAKE_CASE       	=			pipeline_test_mapping[task]['test']
   _SCREAMING_SNAKE_CASE       	=			None

   if framework == "pt":
      _SCREAMING_SNAKE_CASE       	=			getattr(SCREAMING_SNAKE_CASE_      , """model_mapping"""      , SCREAMING_SNAKE_CASE_  )
   elif framework == "tf":
      _SCREAMING_SNAKE_CASE       	=			getattr(SCREAMING_SNAKE_CASE_      , """tf_model_mapping"""      , SCREAMING_SNAKE_CASE_  )

   if mapping is not None:
      _SCREAMING_SNAKE_CASE       	=			dict(mapping.items()  )

   # cache the results
   _SCREAMING_SNAKE_CASE       	=			mapping
   return mapping
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )       ->       Tuple:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			get_framework(SCREAMING_SNAKE_CASE_  )
   if framework is None:
      return None
   _SCREAMING_SNAKE_CASE       	=			get_mapping_for_task(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )
   if mapping is None:
      return None

   _SCREAMING_SNAKE_CASE       	=			list({model_class.config_class for model_class in test_class.all_model_classes}  )
   if len(SCREAMING_SNAKE_CASE_  ) != 1:
      raise ValueError("""There should be exactly one configuration class from `test_class.all_model_classes`."""  )

   # This could be a list/tuple of model classes, but it's rare.
   _SCREAMING_SNAKE_CASE       	=			mapping.get(config_classes[0]      , SCREAMING_SNAKE_CASE_  )
   if isinstance(SCREAMING_SNAKE_CASE_      , (tuple, list)  ):
      _SCREAMING_SNAKE_CASE       	=			sorted(SCREAMING_SNAKE_CASE_      , key=lambda SCREAMING_SNAKE_CASE_  : x.__name__  )

   return model_class
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       Tuple:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			[(task, get_model_for_pipeline_test(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )) for task in pipeline_test_mapping]
   _SCREAMING_SNAKE_CASE       	=			sorted([(task, model) for task, model in mapping if model is not None]      , key=lambda SCREAMING_SNAKE_CASE_  : x[0]  )

   return dict(SCREAMING_SNAKE_CASE_  )
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			get_framework(SCREAMING_SNAKE_CASE_  )
   if framework == "pt":
      _SCREAMING_SNAKE_CASE       	=			'torch'
   _SCREAMING_SNAKE_CASE       	=			'{}'

   _SCREAMING_SNAKE_CASE       	=			get_pipeline_model_mapping(SCREAMING_SNAKE_CASE_  )
   if len(SCREAMING_SNAKE_CASE_  ) == 0:
      return ""

   _SCREAMING_SNAKE_CASE       	=			[]
   for task, model_classes in mapping.items():
      if isinstance(SCREAMING_SNAKE_CASE_      , (tuple, list)  ):
         # A list/tuple of model classes
         _SCREAMING_SNAKE_CASE       	=			'(' + ', '.join([x.__name__ for x in model_classes]  ) + ')'
      else:
         # A single model class
         _SCREAMING_SNAKE_CASE       	=			model_classes.__name__
      texts.append(F"\"{task}\": {value}"  )
   _SCREAMING_SNAKE_CASE       	=			'{' + ', '.join(SCREAMING_SNAKE_CASE_  ) + '}'
   _SCREAMING_SNAKE_CASE       	=			F"pipeline_model_mapping = {text} if is_{framework}_available() else {default_value}"

   return text
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       List[str]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			{'ModelTesterMixin', 'TFModelTesterMixin', 'FlaxModelTesterMixin'}
   if not issubclass(SCREAMING_SNAKE_CASE_      , unittest.TestCase  ):
      return False
   return len(base_class_names.intersection([x.__name__ for x in test_class.__bases__]  )  ) > 0
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       Tuple:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			[x for x in get_test_classes(SCREAMING_SNAKE_CASE_  ) if is_valid_test_class(SCREAMING_SNAKE_CASE_  )]

   _SCREAMING_SNAKE_CASE       	=			None
   for test_class in test_classes:
      # If a test class has defined `pipeline_model_mapping`, let's take it
      if getattr(SCREAMING_SNAKE_CASE_      , """pipeline_model_mapping"""      , SCREAMING_SNAKE_CASE_  ) is not None:
         _SCREAMING_SNAKE_CASE       	=			test_class
         break
    # Take the test class with the shortest name (just a heuristic)
   if target_test_class is None and len(SCREAMING_SNAKE_CASE_  ) > 0:
      _SCREAMING_SNAKE_CASE       	=			sorted(SCREAMING_SNAKE_CASE_      , key=lambda SCREAMING_SNAKE_CASE_  : (len(x.__name__  ), x.__name__)  )[0]

   return target_test_class
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )       ->       int:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			start_idx
   for idx, line in enumerate(lines[start_idx:]  ):
      _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  ) - len(line.lstrip()  )
      if idx == 0 or indent > indent_level or (indent == indent_level and line.strip() == ")"):
         _SCREAMING_SNAKE_CASE       	=			start_idx + idx
      elif idx > 0 and indent <= indent_level:
         # Outside the definition block of `pipeline_model_mapping`
         break

   return end_idx
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_=False  )       ->       Any:




   """simple docstring"""
   if getattr(SCREAMING_SNAKE_CASE_      , """pipeline_model_mapping"""      , SCREAMING_SNAKE_CASE_  ) is not None:
      if not overwrite:
         return "", -1

   _SCREAMING_SNAKE_CASE       	=			get_pipeline_model_mapping_string(SCREAMING_SNAKE_CASE_  )
   if len(SCREAMING_SNAKE_CASE_  ) == 0:
      return "", -1
   _SCREAMING_SNAKE_CASE       	=			line_to_add + '\n'

   # The code defined the class `test_class`
   _SCREAMING_SNAKE_CASE       	=			inspect.getsourcelines(SCREAMING_SNAKE_CASE_  )
   # `inspect` gives the code for an object, including decorator(s) if any.
   # We (only) need the exact line of the class definition.
   for idx, line in enumerate(SCREAMING_SNAKE_CASE_  ):
      if line.lstrip().startswith("""class """  ):
         _SCREAMING_SNAKE_CASE       	=			class_lines[idx:]
         class_start_line_no += idx
         break
   _SCREAMING_SNAKE_CASE       	=			class_start_line_no + len(SCREAMING_SNAKE_CASE_  ) - 1

   # The index in `class_lines` that starts the definition of `all_model_classes`, `all_generative_model_classes` or
   # `pipeline_model_mapping`. This assumes they are defined in such order, and we take the start index of the last
   # block that appears in a `test_class`.
   _SCREAMING_SNAKE_CASE       	=			None
   # The indent level of the line at `class_lines[start_idx]` (if defined)
   _SCREAMING_SNAKE_CASE       	=			0
   # To record if `pipeline_model_mapping` is found in `test_class`.
   _SCREAMING_SNAKE_CASE       	=			None
   for idx, line in enumerate(SCREAMING_SNAKE_CASE_  ):
      if line.strip().startswith("""all_model_classes = """  ):
         _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  ) - len(line.lstrip()  )
         _SCREAMING_SNAKE_CASE       	=			idx
      elif line.strip().startswith("""all_generative_model_classes = """  ):
         _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  ) - len(line.lstrip()  )
         _SCREAMING_SNAKE_CASE       	=			idx
      elif line.strip().startswith("""pipeline_model_mapping = """  ):
         _SCREAMING_SNAKE_CASE       	=			len(SCREAMING_SNAKE_CASE_  ) - len(line.lstrip()  )
         _SCREAMING_SNAKE_CASE       	=			idx
         _SCREAMING_SNAKE_CASE       	=			line
         break

   if start_idx is None:
      return "", -1
   # Find the ending index (inclusive) of the above found block.
   _SCREAMING_SNAKE_CASE       	=			find_block_ending(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )

   # Extract `is_xxx_available()` from existing blocks: some models require specific libraries like `timm` and use
   # `is_timm_available()` instead of `is_torch_available()`.
   # Keep leading and trailing whitespaces
   _SCREAMING_SNAKE_CASE       	=			re.compile(r"""\s(is_\S+?_available\(\))\s"""  )
   for line in class_lines[start_idx : end_idx + 1]:
      _SCREAMING_SNAKE_CASE       	=			r.search(SCREAMING_SNAKE_CASE_  )
      if backend_condition is not None:
         # replace the leading and trailing whitespaces to the space character " ".
         _SCREAMING_SNAKE_CASE       	=			' ' + backend_condition[0][1:-1] + ' '
         _SCREAMING_SNAKE_CASE       	=			r.sub(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )
         break

   if def_line is None:
      # `pipeline_model_mapping` is not defined. The target index is set to the ending index (inclusive) of
      # `all_model_classes` or `all_generative_model_classes`.
      _SCREAMING_SNAKE_CASE       	=			end_idx
   else:
      # `pipeline_model_mapping` is defined. The target index is set to be one **BEFORE** its start index.
      _SCREAMING_SNAKE_CASE       	=			start_idx - 1
      # mark the lines of the currently existing `pipeline_model_mapping` to be removed.
      for idx in range(SCREAMING_SNAKE_CASE_      , end_idx + 1  ):
         # These lines are going to be removed before writing to the test file.
         _SCREAMING_SNAKE_CASE       	=			None  # noqa

    # Make sure the test class is a subclass of `PipelineTesterMixin`.
   _SCREAMING_SNAKE_CASE       	=			[x.__name__ for x in test_class.__bases__]
   if "PipelineTesterMixin" not in parent_classes:
      # Put `PipelineTesterMixin` just before `unittest.TestCase`
      _SCREAMING_SNAKE_CASE       	=			[x for x in parent_classes if x != 'TestCase'] + ['PipelineTesterMixin']
      if "TestCase" in parent_classes:
         # Here we **assume** the original string is always with `unittest.TestCase`.
         _parent_classes.append("""unittest.TestCase"""  )
      _SCREAMING_SNAKE_CASE       	=			', '.join(_parent_classes  )
      for idx, line in enumerate(SCREAMING_SNAKE_CASE_  ):
         # Find the ending of the declaration of `test_class`
         if line.strip().endswith("""):"""  ):
            # mark the lines of the declaration of `test_class` to be removed
            for _idx in range(idx + 1  ):
               _SCREAMING_SNAKE_CASE       	=			None  # noqa
            break
        # Add the new, one-line, class declaration for `test_class`
      _SCREAMING_SNAKE_CASE       	=			F"class {test_class.__name__}({parent_classes}):\n"

   # Add indentation
   _SCREAMING_SNAKE_CASE       	=			' ' * indent_level + line_to_add
   # Insert `pipeline_model_mapping` to `class_lines`.
   # (The line at `target_idx` should be kept by definition!)
   _SCREAMING_SNAKE_CASE       	=			class_lines[: target_idx + 1] + [line_to_add] + class_lines[target_idx + 1 :]
   # Remove the lines that are marked to be removed
   _SCREAMING_SNAKE_CASE       	=			[x for x in class_lines if x is not None]

   # Move from test class to module (in order to write to the test file)
   _SCREAMING_SNAKE_CASE       	=			inspect.getsourcelines(inspect.getmodule(SCREAMING_SNAKE_CASE_  )  )[0]
   # Be careful with the 1-off between line numbers and array indices
   _SCREAMING_SNAKE_CASE       	=			module_lines[: class_start_line_no - 1] + class_lines + module_lines[class_end_line_no:]
   _SCREAMING_SNAKE_CASE       	=			''.join(SCREAMING_SNAKE_CASE_  )

   _SCREAMING_SNAKE_CASE       	=			inspect.getsourcefile(SCREAMING_SNAKE_CASE_  )
   with open(SCREAMING_SNAKE_CASE_      , """w"""      , encoding="""UTF-8"""      , newline="""\n"""  ) as fp:
      fp.write(SCREAMING_SNAKE_CASE_  )

   return line_to_add
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_=False  )       ->       List[Any]:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE       	=			find_test_class(SCREAMING_SNAKE_CASE_  )
   if test_class:
      add_pipeline_model_mapping(SCREAMING_SNAKE_CASE_      , overwrite=SCREAMING_SNAKE_CASE_  )


if __name__ == "__main__":
     UpperCamelCase__ :						str    							=					argparse.ArgumentParser()
     parser.add_argument(
         "--test_file", type=str, help="A path to the test file, starting with the repository's `tests` directory."
     )
     parser.add_argument(
         "--all",
         action="store_true",
         help="If to check and modify all test files.",
     )
     parser.add_argument(
         "--overwrite",
         action="store_true",
         help="If to overwrite a test class if it has already defined `pipeline_model_mapping`.",
     )
     UpperCamelCase__ :						List[str]    							=					parser.parse_args()

     if not args.all and not args.test_file:
          raise ValueError("Please specify either `test_file` or pass `--all` to check/modify all test files.")
     elif args.all and args.test_file:
          raise ValueError("Only one of `--test_file` and `--all` could be specified.")

     UpperCamelCase__ :						Union[str, Any]    							=					[]
     if args.test_file:
          UpperCamelCase__ :						int    							=					[args.test_file]
     else:
          UpperCamelCase__ :						Any    							=					os.path.join("tests", "models", "**", "test_modeling_*.py")
          for test_file in glob.glob(pattern):
               # `Flax` is not concerned at this moment
               if not test_file.startswith("test_modeling_flax_"):
                    test_files.append(test_file)

     for test_file in test_files:
          if test_file in TEST_FILE_TO_IGNORE:
               print(f"""[SKIPPED] {test_file} is skipped as it is in `TEST_FILE_TO_IGNORE` in the file {__file__}.""")
               continue
          add_pipeline_model_mapping_to_test_file(test_file, overwrite=args.overwrite)








'''simple docstring'''



import torch

from diffusers import DDIMScheduler

from .test_schedulers import SchedulerCommonTest

class 				_a			(_lowerCamelCase):





       """simple docstring"""




       SCREAMING_SNAKE_CASE =					(DDIMScheduler,)
       SCREAMING_SNAKE_CASE =					(('eta', 0.0), ('num_inference_steps', 50))






       def     UpperCamelCase			(							self    ,							**A__ )      ->     Optional[int]:
          _SCREAMING_SNAKE_CASE       	=			{
              """num_train_timesteps""": 10_00,
              """beta_start""": 0.0001,
              """beta_end""": 0.02,
              """beta_schedule""": """linear""",
              """clip_sample""": True,
          }

          config.update(**A__ )
          return config






       def     UpperCamelCase			(							self    ,							**A__ )      ->     List[str]:
          _SCREAMING_SNAKE_CASE       	=			self.scheduler_classes[0]
          _SCREAMING_SNAKE_CASE       	=			self.get_scheduler_config(**A__ )
          _SCREAMING_SNAKE_CASE       	=			scheduler_class(**A__ )

          _SCREAMING_SNAKE_CASE	,							_SCREAMING_SNAKE_CASE       	=			10, 0.0

          _SCREAMING_SNAKE_CASE       	=			self.dummy_model()
          _SCREAMING_SNAKE_CASE       	=			self.dummy_sample_deter

          scheduler.set_timesteps(A__ )

          for t in scheduler.timesteps:
             _SCREAMING_SNAKE_CASE       	=			model(A__    ,							A__ )
             _SCREAMING_SNAKE_CASE       	=			scheduler.step(A__    ,							A__    ,							A__    ,							A__ ).prev_sample

          return sample






       def     UpperCamelCase			(							self )      ->     str:
          for timesteps in [1_00, 5_00, 10_00]:
             self.check_over_configs(num_train_timesteps=A__ )






       def     UpperCamelCase			(							self )      ->     int:
          for steps_offset in [0, 1]:
             self.check_over_configs(steps_offset=A__ )

          _SCREAMING_SNAKE_CASE       	=			self.scheduler_classes[0]
          _SCREAMING_SNAKE_CASE       	=			self.get_scheduler_config(steps_offset=1 )
          _SCREAMING_SNAKE_CASE       	=			scheduler_class(**A__ )
          scheduler.set_timesteps(5 )
          assert torch.equal(scheduler.timesteps    ,							torch.LongTensor([8_01, 6_01, 4_01, 2_01, 1] ) )






       def     UpperCamelCase			(							self )      ->     Tuple:
          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=A__    ,							beta_end=A__ )






       def     UpperCamelCase			(							self )      ->     Optional[Any]:
          for schedule in ["linear", "squaredcos_cap_v2"]:
             self.check_over_configs(beta_schedule=A__ )






       def     UpperCamelCase			(							self )      ->     List[str]:
          for prediction_type in ["epsilon", "v_prediction"]:
             self.check_over_configs(prediction_type=A__ )






       def     UpperCamelCase			(							self )      ->     Tuple:
          for clip_sample in [True, False]:
             self.check_over_configs(clip_sample=A__ )






       def     UpperCamelCase			(							self )      ->     Any:
          for timestep_spacing in ["trailing", "leading"]:
             self.check_over_configs(timestep_spacing=A__ )






       def     UpperCamelCase			(							self )      ->     int:
          for rescale_betas_zero_snr in [True, False]:
             self.check_over_configs(rescale_betas_zero_snr=A__ )






       def     UpperCamelCase			(							self )      ->     List[Any]:
          self.check_over_configs(thresholding=A__ )
          for threshold in [0.5, 1.0, 2.0]:
             for prediction_type in ["epsilon", "v_prediction"]:
                self.check_over_configs(
                    thresholding=A__    ,							prediction_type=A__    ,							sample_max_value=A__    ,							)






       def     UpperCamelCase			(							self )      ->     Optional[int]:
          for t in [1, 10, 49]:
             self.check_over_forward(time_step=A__ )






       def     UpperCamelCase			(							self )      ->     Optional[Any]:
          for t, num_inference_steps in zip([1, 10, 50]    ,							[10, 50, 5_00] ):
             self.check_over_forward(time_step=A__    ,							num_inference_steps=A__ )






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






       def     UpperCamelCase			(							self )      ->     Optional[int]:
          _SCREAMING_SNAKE_CASE       	=			self.scheduler_classes[0]
          _SCREAMING_SNAKE_CASE       	=			self.get_scheduler_config()
          _SCREAMING_SNAKE_CASE       	=			scheduler_class(**A__ )

          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.1_4771 ) ) < 1E-5
          assert torch.sum(torch.abs(scheduler._get_variance(9_80    ,							9_60 ) - 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(4_87    ,							4_86 ) - 0.0_0979 ) ) < 1E-5
          assert torch.sum(torch.abs(scheduler._get_variance(9_99    ,							9_98 ) - 0.02 ) ) < 1E-5






       def     UpperCamelCase			(							self )      ->     List[Any]:
          _SCREAMING_SNAKE_CASE       	=			self.full_loop()

          _SCREAMING_SNAKE_CASE       	=			torch.sum(torch.abs(A__ ) )
          _SCREAMING_SNAKE_CASE       	=			torch.mean(torch.abs(A__ ) )

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






       def     UpperCamelCase			(							self )      ->     str:
          _SCREAMING_SNAKE_CASE       	=			self.full_loop(prediction_type="""v_prediction""" )

          _SCREAMING_SNAKE_CASE       	=			torch.sum(torch.abs(A__ ) )
          _SCREAMING_SNAKE_CASE       	=			torch.mean(torch.abs(A__ ) )

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






       def     UpperCamelCase			(							self )      ->     List[Any]:
          # We specify different beta, so that the first alpha is 0.99
          _SCREAMING_SNAKE_CASE       	=			self.full_loop(set_alpha_to_one=A__    ,							beta_start=0.01 )
          _SCREAMING_SNAKE_CASE       	=			torch.sum(torch.abs(A__ ) )
          _SCREAMING_SNAKE_CASE       	=			torch.mean(torch.abs(A__ ) )

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






       def     UpperCamelCase			(							self )      ->     Any:
          # We specify different beta, so that the first alpha is 0.99
          _SCREAMING_SNAKE_CASE       	=			self.full_loop(set_alpha_to_one=A__    ,							beta_start=0.01 )
          _SCREAMING_SNAKE_CASE       	=			torch.sum(torch.abs(A__ ) )
          _SCREAMING_SNAKE_CASE       	=			torch.mean(torch.abs(A__ ) )

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






