





from cva import destroyAllWindows, imread, imshow, waitKey


def 					__SCREAMING_SNAKE_CASE  (							__lowercase:		Dict     ,							__lowercase:		int):



  '''simple docstring'''






  __lowerCAmelCase	,						__lowerCAmelCase			=				img.shape[0], img.shape[1]

  def to_grayscale(__lowercase:		int     ,							__lowercase:		Union[str, Any]     ,							__lowercase:		Optional[Any]):
    return 0.2126 * red + 0.587 * green + 0.114 * blue

  def normalize(__lowercase:		Optional[Any]):
    return min(__lowercase     ,							2_55)

  for i in range(__lowercase):
    for j in range(__lowercase):
      __lowerCAmelCase			=				int(to_grayscale(*img[i][j]))
      __lowerCAmelCase			=				[
          normalize(__lowercase),
          normalize(greyscale + factor),
          normalize(greyscale + 2 * factor),
      ]

  return img


if __name__ == "__main__":
      # read original image
      __lowercase													=			{
          percentage: imread("""image_data/lena.jpg""", 1) for percentage in (10, 20, 30, 40)
      }

      for percentage, img in images.items():
            make_sepia(img, percentage)

      for percentage, img in images.items():
            imshow(f"""Original image with sepia (factor: {percentage})""", img)

      waitKey(0)
      destroyAllWindows()







import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_multi_gpu,
    require_single_gpu,
    test_sync,
)
from accelerate.utils import patch_environment

class   __snake_case				(			unittest.TestCase   ):






    '''simple docstring'''





    def 	A		(   self						:		int							):

      """simple docstring"""





      __lowerCAmelCase			=				inspect.getfile(accelerate.test_utils							)
      __lowerCAmelCase			=				os.path.sep.join(mod_file.split(os.path.sep							)[:-1] + ['''scripts''', '''test_sync.py''']							)





    @require_cpu
    def 	A		(   self						:		str							):

      """simple docstring"""





      debug_launcher(test_sync.main			,						num_processes=1							)





    @require_cpu
    def 	A		(   self						:		List[str]							):

      """simple docstring"""





      debug_launcher(test_sync.main							)





    @require_single_gpu
    def 	A		(   self						:		Optional[Any]							):

      """simple docstring"""





      test_sync.main()





    @require_multi_gpu
    def 	A		(   self						:		Union[str, Any]							):

      """simple docstring"""





      print(f'''Found {torch.cuda.device_count()} devices.'''							)
      __lowerCAmelCase			=				['''torchrun''', f'''--nproc_per_node={torch.cuda.device_count()}''', self.test_file_path]
      with patch_environment(omp_num_threads=1							):
        execute_subprocess_async(snake_case			,						env=os.environ.copy()							)
