



"""simple docstring"""




from multiprocessing import Lock, Pipe, Process

# lock used to ensure that two processes do not access a pipe at the same time
_lowerCAmelCase    : List[str]							=							Lock()

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						str						,  SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						Union[str, Any]						,  SCREAMING_SNAKE_CASE__     :						List[Any]    )  ->       int:





     '''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(SCREAMING_SNAKE_CASE__    )
               process_lock.release()

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

               # take the lower value since you are on the left
               _UpperCAmelCase      :     Tuple        =   min(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
          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(SCREAMING_SNAKE_CASE__    )
               process_lock.release()

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

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

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Union[str, Any]    )  ->       Tuple:





     '''simple docstring'''

     _UpperCAmelCase      :     str        =   []
     _UpperCAmelCase      :     List[Any]        =   []
     # 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
     _UpperCAmelCase      :     Union[str, Any]        =   Pipe()
     _UpperCAmelCase      :     str        =   Pipe()
     process_array_.append(
         Process(
             target=SCREAMING_SNAKE_CASE__						,  args=(0, arr[0], None, temp_rs, None, temp_rr, result_pipe[0])						,  )    )
     _UpperCAmelCase      :     Optional[Any]        =   temp_rs
     _UpperCAmelCase      :     str        =   temp_rr

     for i in range(1						,  len(SCREAMING_SNAKE_CASE__    ) - 1    ):
          _UpperCAmelCase      :     Optional[int]        =   Pipe()
          _UpperCAmelCase      :     str        =   Pipe()
          process_array_.append(
              Process(
                  target=SCREAMING_SNAKE_CASE__						,  args=(i, arr[i], temp_ls, temp_rs, temp_lr, temp_rr, result_pipe[i])						,  )    )
          _UpperCAmelCase      :     Tuple        =   temp_rs
          _UpperCAmelCase      :     List[Any]        =   temp_rr

     process_array_.append(
         Process(
             target=SCREAMING_SNAKE_CASE__						,  args=(
                 len(SCREAMING_SNAKE_CASE__    ) - 1,
                 arr[len(SCREAMING_SNAKE_CASE__    ) - 1],
                 temp_ls,
                 None,
                 temp_lr,
                 None,
                 result_pipe[len(SCREAMING_SNAKE_CASE__    ) - 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(SCREAMING_SNAKE_CASE__    )    ):
          _UpperCAmelCase      :     Tuple        =   result_pipe[p][0].recv()
          process_array_[p].join()
     return arr

def 						__snake_case						(				)  ->       Optional[Any]:





     '''simple docstring'''

     _UpperCAmelCase      :     int        =   list(range(10						,  0						,  -1    )    )
     print("Initial List"    )
     print(*SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     str        =   odd_even_transposition(SCREAMING_SNAKE_CASE__    )
     print("Sorted List\n"    )
     print(*SCREAMING_SNAKE_CASE__    )


if __name__ == "__main__":
 main()





"""simple docstring"""




import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
_lowerCAmelCase    : Dict							=							"src/transformers"


# This is to make sure the transformers module imported is the one in the repo.
_lowerCAmelCase    : List[Any]							=							importlib.util.spec_from_file_location(
    "transformers",
    os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
_lowerCAmelCase    : Tuple							=							spec.loader.load_module()

_lowerCAmelCase    : Tuple							=							transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
_lowerCAmelCase    : Optional[int]							=							re.compile("\[(.+?)\]\((https://huggingface\.co/.+?)\)")


_lowerCAmelCase    : Optional[int]							=							{
    "CLIPConfigMixin",
    "DecisionTransformerConfigMixin",
    "EncoderDecoderConfigMixin",
    "RagConfigMixin",
    "SpeechEncoderDecoderConfigMixin",
    "VisionEncoderDecoderConfigMixin",
    "VisionTextDualEncoderConfigMixin",
}

def 						__snake_case						(				)  ->       Dict:





     '''simple docstring'''

     _UpperCAmelCase      :     List[str]        =   []

     for config_class in list(CONFIG_MAPPING.values()    ):
          _UpperCAmelCase      :     Union[str, Any]        =   False

          # source code of `config_class`
          _UpperCAmelCase      :     Optional[int]        =   inspect.getsource(SCREAMING_SNAKE_CASE__    )
          _UpperCAmelCase      :     List[Any]        =   _re_checkpoint.findall(SCREAMING_SNAKE_CASE__    )

          for checkpoint in checkpoints:
               # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
               # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
               _UpperCAmelCase    ,	_UpperCAmelCase      :     List[Any]        =   checkpoint

               # verify the checkpoint name corresponds to the checkpoint link
               _UpperCAmelCase      :     Optional[Any]        =   f'https://huggingface.co/{ckpt_name}'
               if ckpt_link == ckpt_link_from_name:
                    _UpperCAmelCase      :     Optional[Any]        =   True
                    break

          _UpperCAmelCase      :     int        =   config_class.__name__
          if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(SCREAMING_SNAKE_CASE__    )

     if len(SCREAMING_SNAKE_CASE__    ) > 0:
          _UpperCAmelCase      :     List[str]        =   "\n".join(sorted(SCREAMING_SNAKE_CASE__    )    )
          raise ValueError(f'The following configurations don\'t contain any valid checkpoint:\n{message}'    )


if __name__ == "__main__":
 check_config_docstrings_have_checkpoints()
