






'''simple docstring'''







import operator





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase = False       ,    UpperCamelCase = None   )   -> Any:
							lowerCamelCase__      :			Optional[int] 						= operator.lt if reverse else operator.gt
							lowerCamelCase__      :			List[Any] 						= solution or []

							if not arr:
														return solution

							lowerCamelCase__      :			Union[str, Any] 						= [arr.pop(0   )]
							for i, item in enumerate(UpperCamelCase   ):
														if _operator(UpperCamelCase       ,    sublist[-1]   ):
																					sublist.append(UpperCamelCase   )
																					arr.pop(UpperCamelCase   )

    #  merging sublist into solution list
							if not solution:
														solution.extend(UpperCamelCase   )
							else:
														while sublist:
																					lowerCamelCase__      :			Tuple 						= sublist.pop(0   )
																					for i, xx in enumerate(UpperCamelCase   ):
																												if not _operator(UpperCamelCase       ,    UpperCamelCase   ):
																																			solution.insert(UpperCamelCase       ,    UpperCamelCase   )
																																			break
																					else:
																												solution.append(UpperCamelCase   )

							strand_sort(UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase   )
							return solution


if __name__ == "__main__":
			assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
			assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]







'''simple docstring'''







from ...utils import is_torch_available, is_transformers_available


if is_transformers_available() and is_torch_available():
			from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline

