





'''simple docstring'''




from PIL import Image





def 	__lowerCamelCase			(      __lowerCAmelCase       :							Image		)		->  Image:
   snake_case						,    snake_case 						=   image.size
   snake_case 						=   0
   snake_case 						=   image.load()
   for i in range(__lowerCAmelCase		):
      for j in range(__lowerCAmelCase		):
         snake_case 						=   pixels[j, i]
         mean += pixel
   mean //= width * height

   for j in range(__lowerCAmelCase		):
      for i in range(__lowerCAmelCase		):
         snake_case 						=   2_55 if pixels[i, j] > mean else 0
   return image


if __name__ == "__main__":
 _SCREAMING_SNAKE_CASE							     =			mean_threshold(Image.open("path_to_image").convert("L"))
 image.save("output_image_path")








'''simple docstring'''

import unittest

from accelerate import debug_launcher
from accelerate.test_utils import require_cpu, test_ops, test_script
@require_cpu
class 							__lowerCAmelCase	(       unittest.TestCase					):






       """simple docstring"""





       def snake_case__		(				self  :						str	)       ->	Optional[int]:

            '''simple docstring'''




            debug_launcher(test_script.main	)







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

            '''simple docstring'''




            debug_launcher(test_ops.main	)



