






from multiprocessing import Lock, Pipe, Process

# lock used to ensure that two processes do not access a pipe at the same time
__UpperCamelCase   :   Any      =    Lock()





def 					snake_case	(  lowerCamelCase					,	lowerCamelCase					,	lowerCamelCase					,	lowerCamelCase					,	lowerCamelCase					,	lowerCamelCase					,	lowerCamelCase       ):




	'''simple docstring'''







	global process_lock

	# we perform n swaps since after n swaps we know we are sorted
	# we *could* stop early if we are sorted already, but it takes as long to
	# find out we are sorted as it does to sort the list with this algorithm
	for i in range(0					,	10       ):
		if (i + position) % 2 == 0 and r_send is not None:
			# send your value to your right neighbor
			process_lock.acquire()
			r_send[1].send(a_       )
			process_lock.release()

			# receive your right neighbor's value
			process_lock.acquire()
			__lowercase   							=	rr_cv[0].recv()
			process_lock.release()

			# take the lower value since you are on the left
			__lowercase   							=	min(a_					,	a_       )
		elif (i + position) % 2 != 0 and l_send is not None:
			# send your value to your left neighbor
			process_lock.acquire()
			l_send[1].send(a_       )
			process_lock.release()

			# receive your left neighbor's value
			process_lock.acquire()
			__lowercase   							=	lr_cv[0].recv()
			process_lock.release()

			# take the higher value since you are on the right
			__lowercase   							=	max(a_					,	a_       )
		# after all swaps are performed, send the values back to main
	result_pipe[1].send(a_       )





def 					snake_case	(  lowerCamelCase       ):




	'''simple docstring'''







	__lowercase   							=	[]
	__lowercase   							=	[]
	# initialize the list of pipes where the values will be retrieved
	for _ in arr:
		result_pipe.append(Pipe()       )
	# creates the processes
	# the first and last process only have one neighbor so they are made outside
	# of the loop
	__lowercase   							=	Pipe()
	__lowercase   							=	Pipe()
	process_array_.append(
	    Process(
	        target=a_					,	args=(0, arr[0], None, temp_rs, None, temp_rr, result_pipe[0])					,	)       )
	__lowercase   							=	temp_rs
	__lowercase   							=	temp_rr

	for i in range(1					,	len(a_       ) - 1       ):
		__lowercase   							=	Pipe()
		__lowercase   							=	Pipe()
		process_array_.append(
		    Process(
		        target=a_					,	args=(i, arr[i], temp_ls, temp_rs, temp_lr, temp_rr, result_pipe[i])					,	)       )
		__lowercase   							=	temp_rs
		__lowercase   							=	temp_rr

	process_array_.append(
	    Process(
	        target=a_					,	args=(
	            len(a_       ) - 1,
	            arr[len(a_       ) - 1],
	            temp_ls,
	            None,
	            temp_lr,
	            None,
	            result_pipe[len(a_       ) - 1],
	        )					,	)       )

	# start the processes
	for p in process_array_:
		p.start()

	# wait for the processes to end and write their values to the list
	for p in range(0					,	len(a_       )       ):
		__lowercase   							=	result_pipe[p][0].recv()
		process_array_[p].join()
	return arr





def 					snake_case	(  ):




	'''simple docstring'''







	__lowercase   							=	list(range(10					,	0					,	-1       )       )
	print("""Initial List"""       )
	print(*a_       )
	__lowercase   							=	odd_even_transposition(a_       )
	print("""Sorted List\n"""       )
	print(*a_       )


if __name__ == "__main__":
						main()







'''simple docstring'''


import os

import pytest
import yaml

from datasets.features.features import Features, Value
from datasets.info import DatasetInfo, DatasetInfosDict


@pytest.mark.parametrize(
    'files'					,       [
        ['full:README.md', 'dataset_infos.json'],
        ['empty:README.md', 'dataset_infos.json'],
        ['dataset_infos.json'],
        ['full:README.md'],
    ]					,       )
def     SCREAMING_SNAKE_CASE							(   a_						:				Tuple					,       a_						:				Dict      ):
  __a								=       tmp_path_factory.mktemp('dset_infos_dir'      )
  if "full:README.md" in files:
    with open(dataset_infos_dir / 'README.md'					,       'w'      ) as f:
      f.write('---\ndataset_info:\n  dataset_size: 42\n---'      )
  if "empty:README.md" in files:
    with open(dataset_infos_dir / 'README.md'					,       'w'      ) as f:
      f.write(''      )
    # we want to support dataset_infos.json for backward compatibility
  if "dataset_infos.json" in files:
    with open(dataset_infos_dir / 'dataset_infos.json'					,       'w'      ) as f:
      f.write('{"default": {"dataset_size": 42}}'      )
  __a								=       DatasetInfosDict.from_directory(a_      )
  assert dataset_infos
  assert dataset_infos["default"].dataset_size == 42


@pytest.mark.parametrize(
    'dataset_info'					,       [
        DatasetInfo(),
        DatasetInfo(
            description='foo'					,       features=Features({'a': Value('int32'      )}      )					,       builder_name='builder'					,       config_name='config'					,       version='1.0.0'					,       splits=[{'name': 'train'}]					,       download_size=42					,       ),
    ]					,       )
def     SCREAMING_SNAKE_CASE							(   a_						:				Optional[int]					,       a_						:				DatasetInfo      ):
  __a								=       str(a_      )
  dataset_info.write_to_directory(a_      )
  __a								=       DatasetInfo.from_directory(a_      )
  assert dataset_info == reloaded
  assert os.path.exists(os.path.join(a_					,       'dataset_info.json'      )      )


def     SCREAMING_SNAKE_CASE							(   ):
  __a								=       DatasetInfo(
      description='foo'					,       citation='bar'					,       homepage='https://foo.bar'					,       license='CC0'					,       features=Features({'a': Value('int32'      )}      )					,       post_processed={}					,       supervised_keys=()					,       task_templates=[]					,       builder_name='builder'					,       config_name='config'					,       version='1.0.0'					,       splits=[{'name': 'train', 'num_examples': 42}]					,       download_checksums={}					,       download_size=1337					,       post_processing_size=442					,       dataset_size=1234					,       size_in_bytes=1337 + 442 + 1234					,       )
  __a								=       dataset_info._to_yaml_dict()
  assert sorted(a_      ) == sorted(DatasetInfo._INCLUDED_INFO_IN_YAML      )
  for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
    assert key in dataset_info_yaml_dict
    assert isinstance(dataset_info_yaml_dict[key]					,       (list, dict, int, str)      )
  __a								=       yaml.safe_dump(a_      )
  __a								=       yaml.safe_load(a_      )
  assert dataset_info_yaml_dict == reloaded


def     SCREAMING_SNAKE_CASE							(   ):
  __a								=       DatasetInfo()
  __a								=       dataset_info._to_yaml_dict()
  assert dataset_info_yaml_dict == {}


@pytest.mark.parametrize(
    'dataset_infos_dict'					,       [
        DatasetInfosDict(),
        DatasetInfosDict({'default': DatasetInfo()}      ),
        DatasetInfosDict({'my_config_name': DatasetInfo()}      ),
        DatasetInfosDict(
            {
                'default': DatasetInfo(
                    description='foo'					,       features=Features({'a': Value('int32'      )}      )					,       builder_name='builder'					,       config_name='config'					,       version='1.0.0'					,       splits=[{'name': 'train'}]					,       download_size=42					,       )
            }      ),
        DatasetInfosDict(
            {
                'v1': DatasetInfo(dataset_size=42      ),
                'v2': DatasetInfo(dataset_size=1337      ),
            }      ),
    ]					,       )
def     SCREAMING_SNAKE_CASE							(   a_						:				List[str]					,       a_						:				DatasetInfosDict      ):
  __a								=       str(a_      )
  dataset_infos_dict.write_to_directory(a_      )
  __a								=       DatasetInfosDict.from_directory(a_      )

  # the config_name of the dataset_infos_dict take over the attribute
  for config_name, dataset_info in dataset_infos_dict.items():
    __a								=       config_name
    # the yaml representation doesn't include fields like description or citation
    # so we just test that we can recover what we can from the yaml
    __a								=       DatasetInfo._from_yaml_dict(dataset_info._to_yaml_dict()      )
  assert dataset_infos_dict == reloaded

  if dataset_infos_dict:
    assert os.path.exists(os.path.join(a_					,       'README.md'      )      )



