

import tempfile
import unittest

from make_student import create_student_by_copying_alternating_layers

from transformers import AutoConfig
from transformers.file_utils import cached_property
from transformers.testing_utils import require_torch


_UpperCAmelCase	:     Optional[Any]		       = """sshleifer/bart-tiny-random"""
_UpperCAmelCase	:     Optional[int]		       = """patrickvonplaten/t5-tiny-random"""







@require_torch
class 				lowercase       ( unittest.TestCase    ):




				@cached_property
				def 					a							(      self ):
											return AutoConfig.from_pretrained(snake_case )




				def 					a							(      self ):
											snake_case_       ,					*snake_case_           =					create_student_by_copying_alternating_layers(snake_case   ,     tempfile.mkdtemp()   ,     e=1   ,     d=1 )
											self.assertEqual(student.config.num_hidden_layers   ,     1 )




				def 					a							(      self ):
											snake_case_       ,					*snake_case_           =					create_student_by_copying_alternating_layers(snake_case   ,     tempfile.mkdtemp()   ,     e=1   ,     d=snake_case )




				def 					a							(      self ):
											snake_case_       ,					*snake_case_           =					create_student_by_copying_alternating_layers(snake_case   ,     tempfile.mkdtemp()   ,     e=1   ,     d=snake_case )
											self.assertEqual(student.config.encoder_layers   ,     1 )
											self.assertEqual(student.config.decoder_layers   ,     self.teacher_config.encoder_layers )




				def 					a							(      self ):
											snake_case_       ,					*snake_case_           =					create_student_by_copying_alternating_layers(snake_case   ,     tempfile.mkdtemp()   ,     e=1   ,     d=1 )
											self.assertEqual(student.config.encoder_layers   ,     1 )
											self.assertEqual(student.config.decoder_layers   ,     1 )




				def 					a							(      self ):
											with self.assertRaises(snake_case ):
																		create_student_by_copying_alternating_layers(snake_case   ,     tempfile.mkdtemp()   ,     e=snake_case   ,     d=snake_case )







def       __lowerCamelCase			(				UpperCamelCase__   ):







							'''simple docstring'''






							if not nums:  # Makes sure that the list is not empty
														raise ValueError('List is empty'   )

							snake_case_           =					sum(UpperCamelCase__   ) / len(UpperCamelCase__   )  # Calculate the average
							return sum(abs(x - average   ) for x in nums   ) / len(UpperCamelCase__   )


if __name__ == "__main__":
					import doctest

					doctest.testmod()




