






"""simple docstring"""






import pytest

import datasets.config
from datasets.utils.info_utils import is_small_dataset



@pytest.mark.parametrize('dataset_size'       ,[None, 400 * 2**20, 600 * 2**20]				)
@pytest.mark.parametrize('input_in_memory_max_size'       ,['default', 0, 100 * 2**20, 900 * 2**20]				)
def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				):
				if input_in_memory_max_size != "default":
								monkeypatch.setattr(datasets.config       ,'IN_MEMORY_MAX_SIZE'       ,lowerCAmelCase__				)
				A__							 =       datasets.config.IN_MEMORY_MAX_SIZE
				if input_in_memory_max_size == "default":
								assert in_memory_max_size == 0
				else:
								assert in_memory_max_size == input_in_memory_max_size
				if dataset_size and in_memory_max_size:
								A__							 =       dataset_size < in_memory_max_size
				else:
								A__							 =       False
				A__							 =       is_small_dataset(lowerCAmelCase__				)
				assert result == expected










"""simple docstring"""






from PIL import Image



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__ ,			A__							 =       image.size
				A__							 =       0
				A__							 =       image.load()
				for i in range(lowerCAmelCase__				):
								for j in range(lowerCAmelCase__				):
												A__							 =       pixels[j, i]
												mean += pixel
				mean //= width * height

				for j in range(lowerCAmelCase__				):
								for i in range(lowerCAmelCase__				):
												A__							 =       255 if pixels[i, j] > mean else 0
				return image


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


