



'''simple docstring'''





def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase      ):



    """simple docstring"""





    if len(UpperCamelCase      ) <= 1:
        return [tuple(UpperCamelCase      )]

    lowerCAmelCase__			:  str											= []

    def generate(UpperCamelCase							,   UpperCamelCase      ):
        if k == 1:
            res.append(tuple(arr[:]      )      )
            return

        generate(k - 1							,   UpperCamelCase      )

        for i in range(k - 1      ):
            if k % 2 == 0:  # k is even
                lowerCAmelCase__			:  Optional[int]											= arr[k - 1], arr[i]
            else:  # k is odd
                lowerCAmelCase__			:  Union[str, Any]											= arr[k - 1], arr[0]
            generate(k - 1							,   UpperCamelCase      )

    generate(len(UpperCamelCase      )							,   UpperCamelCase      )
    return res


if __name__ == "__main__":
 _lowerCAmelCase										=     input('''Enter numbers separated by a comma:\n''').strip()
 _lowerCAmelCase										=     [int(item) for item in user_input.split(''',''')]
 print(heaps(arr))







'''simple docstring'''





import unittest

import numpy as np
import requests

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
 import torch

 from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
 _lowerCAmelCase										=     False

if is_vision_available():
 from PIL import Image

 from transformers import PixaStructImageProcessor






class 	lowerCAmelCase_(    unittest.TestCase					):
  '''simple docstring'''




  def __init__(   self  ,__UpperCAmelCase  ,__UpperCAmelCase=7  ,__UpperCAmelCase=3  ,__UpperCAmelCase=18  ,__UpperCAmelCase=30  ,__UpperCAmelCase=400  ,__UpperCAmelCase=None  ,__UpperCAmelCase=True  ,__UpperCAmelCase=True  ,__UpperCAmelCase=None  ,)   ->		Optional[Any]:
      lowerCAmelCase__			:  Optional[Any]											= size if size is not None else {"""height""": 20, """width""": 20}
      lowerCAmelCase__			:  List[Any]											= parent
      lowerCAmelCase__			:  List[str]											= batch_size
      lowerCAmelCase__			:  Tuple											= num_channels
      lowerCAmelCase__			:  Optional[int]											= image_size
      lowerCAmelCase__			:  Optional[Any]											= min_resolution
      lowerCAmelCase__			:  Tuple											= max_resolution
      lowerCAmelCase__			:  List[Any]											= size
      lowerCAmelCase__			:  List[str]											= do_normalize
      lowerCAmelCase__			:  Optional[int]											= do_convert_rgb
      lowerCAmelCase__			:  str											= [512, 1024, 2048, 4096]
      lowerCAmelCase__			:  int											= patch_size if patch_size is not None else {"""height""": 16, """width""": 16}




  def 							UpperCAmelCase_     (   self				)   ->		Optional[int]:
      return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}






  def 							UpperCAmelCase_     (   self				)   ->		Dict:
      lowerCAmelCase__			:  Optional[Any]											= """https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"""
      lowerCAmelCase__			:  Union[str, Any]											= Image.open(requests.get(__UpperCAmelCase  ,stream=__UpperCAmelCase				).raw				).convert("""RGB"""				)
      return raw_image







@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11						,			reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''						,			)
@require_torch
@require_vision
class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_						,			unittest.TestCase					):
  '''simple docstring'''




  __lowercase							:				Union[str, Any]           =				PixaStructImageProcessor if is_vision_available() else None




  def 							UpperCAmelCase_     (   self				)   ->		List[str]:
      lowerCAmelCase__			:  Union[str, Any]											= PixaStructImageProcessingTester(self				)




  @property
  def 							UpperCAmelCase_     (   self				)   ->		Dict:
      return self.image_processor_tester.prepare_image_processor_dict()




  def 							UpperCAmelCase_     (   self				)   ->		Optional[Any]:
      lowerCAmelCase__			:  Dict											= self.image_processing_class(**self.image_processor_dict				)
      self.assertTrue(hasattr(__UpperCAmelCase  ,"""do_normalize"""				)				)
      self.assertTrue(hasattr(__UpperCAmelCase  ,"""do_convert_rgb"""				)				)




  def 							UpperCAmelCase_     (   self				)   ->		Optional[int]:
      lowerCAmelCase__			:  List[Any]											= self.image_processor_tester.prepare_dummy_image()

      lowerCAmelCase__			:  List[Any]											= self.image_processing_class(**self.image_processor_dict				)
      lowerCAmelCase__			:  str											= 2048

      lowerCAmelCase__			:  Tuple											= image_processor(__UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				)
      self.assertTrue(torch.allclose(inputs.flattened_patches.mean()  ,torch.tensor(0.0_6_0_6				)  ,atol=1E-3  ,rtol=1E-3				)				)




  def 							UpperCAmelCase_     (   self				)   ->		str:
      # Initialize image_processor
      lowerCAmelCase__			:  int											= self.image_processing_class(**self.image_processor_dict				)
      # create random PIL images
      lowerCAmelCase__			:  int											= prepare_image_inputs(self.image_processor_tester  ,equal_resolution=__UpperCAmelCase				)
      for image in image_inputs:
          self.assertIsInstance(__UpperCAmelCase  ,Image.Image				)

      # Test not batched input
      lowerCAmelCase__			:  List[str]											= (
          (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
          * self.image_processor_tester.num_channels
      ) + 2

      for max_patch in self.image_processor_tester.max_patches:
          # Test not batched input
          lowerCAmelCase__			:  str											= image_processor(
              image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(1, max_patch, expected_hidden_dim)  ,)

          # Test batched
          lowerCAmelCase__			:  Any											= image_processor(
              __UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)  ,)




  def 							UpperCAmelCase_     (   self				)   ->		Any:
      # Initialize image_processor
      lowerCAmelCase__			:  Optional[int]											= self.image_processing_class(**self.image_processor_dict				)
      # create random PIL images
      lowerCAmelCase__			:  Optional[int]											= prepare_image_inputs(self.image_processor_tester  ,equal_resolution=__UpperCAmelCase				)
      for image in image_inputs:
          self.assertIsInstance(__UpperCAmelCase  ,Image.Image				)

      # Test not batched input
      lowerCAmelCase__			:  Tuple											= (
          (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
          * self.image_processor_tester.num_channels
      ) + 2

      lowerCAmelCase__			:  Optional[int]											= True

      for max_patch in self.image_processor_tester.max_patches:
          # Test not batched input
          with self.assertRaises(__UpperCAmelCase				):
              lowerCAmelCase__			:  Any											= image_processor(
                  image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches

          lowerCAmelCase__			:  Optional[Any]											= """Hello"""

          lowerCAmelCase__			:  List[str]											= image_processor(
              image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase  ,header_text=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(1, max_patch, expected_hidden_dim)  ,)

          # Test batched
          lowerCAmelCase__			:  str											= image_processor(
              __UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase  ,header_text=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)  ,)




  def 							UpperCAmelCase_     (   self				)   ->		Tuple:
      # Initialize image_processor
      lowerCAmelCase__			:  Optional[Any]											= self.image_processing_class(**self.image_processor_dict				)
      # create random numpy tensors
      lowerCAmelCase__			:  List[str]											= prepare_image_inputs(self.image_processor_tester  ,equal_resolution=__UpperCAmelCase  ,numpify=__UpperCAmelCase				)
      for image in image_inputs:
          self.assertIsInstance(__UpperCAmelCase  ,np.ndarray				)

      lowerCAmelCase__			:  Tuple											= (
          (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
          * self.image_processor_tester.num_channels
      ) + 2

      for max_patch in self.image_processor_tester.max_patches:
          # Test not batched input
          lowerCAmelCase__			:  Any											= image_processor(
              image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(1, max_patch, expected_hidden_dim)  ,)

          # Test batched
          lowerCAmelCase__			:  int											= image_processor(
              __UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)  ,)






  def 							UpperCAmelCase_     (   self				)   ->		Optional[int]:
      # Initialize image_processor
      lowerCAmelCase__			:  Tuple											= self.image_processing_class(**self.image_processor_dict				)
      # create random PyTorch tensors
      lowerCAmelCase__			:  int											= prepare_image_inputs(self.image_processor_tester  ,equal_resolution=__UpperCAmelCase  ,torchify=__UpperCAmelCase				)
      for image in image_inputs:
          self.assertIsInstance(__UpperCAmelCase  ,torch.Tensor				)

      # Test not batched input
      lowerCAmelCase__			:  Optional[int]											= (
          (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
          * self.image_processor_tester.num_channels
      ) + 2

      for max_patch in self.image_processor_tester.max_patches:
          # Test not batched input
          lowerCAmelCase__			:  Dict											= image_processor(
              image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(1, max_patch, expected_hidden_dim)  ,)

          # Test batched
          lowerCAmelCase__			:  Union[str, Any]											= image_processor(
              __UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)  ,)







@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11						,			reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''						,			)
@require_torch
@require_vision
class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_						,			unittest.TestCase					):
  '''simple docstring'''




  __lowercase							:				Optional[int]           =				PixaStructImageProcessor if is_vision_available() else None




  def 							UpperCAmelCase_     (   self				)   ->		List[Any]:
      lowerCAmelCase__			:  Dict											= PixaStructImageProcessingTester(self  ,num_channels=4				)
      lowerCAmelCase__			:  str											= 3




  @property
  def 							UpperCAmelCase_     (   self				)   ->		Tuple:
      return self.image_processor_tester.prepare_image_processor_dict()




  def 							UpperCAmelCase_     (   self				)   ->		Dict:
      lowerCAmelCase__			:  Union[str, Any]											= self.image_processing_class(**self.image_processor_dict				)
      self.assertTrue(hasattr(__UpperCAmelCase  ,"""do_normalize"""				)				)
      self.assertTrue(hasattr(__UpperCAmelCase  ,"""do_convert_rgb"""				)				)






  def 							UpperCAmelCase_     (   self				)   ->		Optional[Any]:
      # Initialize image_processor
      lowerCAmelCase__			:  Optional[Any]											= self.image_processing_class(**self.image_processor_dict				)
      # create random PIL images
      lowerCAmelCase__			:  Dict											= prepare_image_inputs(self.image_processor_tester  ,equal_resolution=__UpperCAmelCase				)
      for image in image_inputs:
          self.assertIsInstance(__UpperCAmelCase  ,Image.Image				)

      # Test not batched input
      lowerCAmelCase__			:  Dict											= (
          (self.image_processor_tester.patch_size["""height"""] * self.image_processor_tester.patch_size["""width"""])
          * (self.image_processor_tester.num_channels - 1)
      ) + 2

      for max_patch in self.image_processor_tester.max_patches:
          # Test not batched input
          lowerCAmelCase__			:  int											= image_processor(
              image_inputs[0]  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(1, max_patch, expected_hidden_dim)  ,)

          # Test batched
          lowerCAmelCase__			:  Dict											= image_processor(
              __UpperCAmelCase  ,return_tensors="""pt"""  ,max_patches=__UpperCAmelCase				).flattened_patches
          self.assertEqual(
              encoded_images.shape  ,(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)  ,)


