'''simple docstring'''

def  _lowerCAmelCase				(				__a			,      __a      )  ->      str:
     '''simple docstring'''







     if not isinstance(__a			,      __a      ):
          raise TypeError("""plaintext must be a string"""      )
     if not isinstance(__a			,      __a      ):
          raise TypeError("""key must be a string"""      )

     if not plaintext:
          raise ValueError("""plaintext is empty"""      )
     if not key:
          raise ValueError("""key is empty"""      )

     key += plaintext
     _UpperCamelCase  :Optional[Any]       =plaintext.lower()
     _UpperCamelCase  :List[str]       =key.lower()
     _UpperCamelCase  :Union[str, Any]       =0
     _UpperCamelCase  :Dict       =0
     _UpperCamelCase  :Any       =""""""
     while plaintext_iterator < len(__a      ):
          if (
              ord(plaintext[plaintext_iterator]      ) < 97
              or ord(plaintext[plaintext_iterator]      ) > 1_22
          ):
               ciphertext += plaintext[plaintext_iterator]
               plaintext_iterator += 1
          elif ord(key[key_iterator]      ) < 97 or ord(key[key_iterator]      ) > 1_22:
               key_iterator += 1
          else:
               ciphertext += chr(
                   (
                       (ord(plaintext[plaintext_iterator]      ) - 97 + ord(key[key_iterator]      ))
                       - 97
                   )
                   % 26
                   + 97      )
               key_iterator += 1
               plaintext_iterator += 1
     return ciphertext



def  _lowerCAmelCase				(				__a			,      __a      )  ->      str:
     '''simple docstring'''







     if not isinstance(__a			,      __a      ):
          raise TypeError("""ciphertext must be a string"""      )
     if not isinstance(__a			,      __a      ):
          raise TypeError("""key must be a string"""      )

     if not ciphertext:
          raise ValueError("""ciphertext is empty"""      )
     if not key:
          raise ValueError("""key is empty"""      )

     _UpperCamelCase  :Tuple       =key.lower()
     _UpperCamelCase  :List[Any]       =0
     _UpperCamelCase  :List[str]       =0
     _UpperCamelCase  :Tuple       =""""""
     while ciphertext_iterator < len(__a      ):
          if (
              ord(ciphertext[ciphertext_iterator]      ) < 97
              or ord(ciphertext[ciphertext_iterator]      ) > 1_22
          ):
               plaintext += ciphertext[ciphertext_iterator]
          else:
               plaintext += chr(
                   (ord(ciphertext[ciphertext_iterator]      ) - ord(key[key_iterator]      )) % 26
                   + 97      )
               key += chr(
                   (ord(ciphertext[ciphertext_iterator]      ) - ord(key[key_iterator]      )) % 26
                   + 97      )
               key_iterator += 1
          ciphertext_iterator += 1
     return plaintext


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      _lowerCamelCase :				Union[str, Any]														= int(input("""Type 1 to encrypt or 2 to decrypt:"""))
      if operation == 1:
            _lowerCamelCase :				Any														= input("""Typeplaintext to be encrypted:\n""")
            _lowerCamelCase :				int														= input("""Type the key:\n""")
            print(encrypt(plaintext, key))
      elif operation == 2:
            _lowerCamelCase :				List[str]														= input("""Type the ciphertext to be decrypted:\n""")
            _lowerCamelCase :				Union[str, Any]														= input("""Type the key:\n""")
            print(decrypt(ciphertext, key))
      decrypt("""jsqqs avvwo""", """coffee""")
'''simple docstring'''

import copy
import inspect

from transformers.testing_utils import require_torch, torch_device
from transformers.utils.backbone_utils import BackboneType




@require_torch
class    lowerCamelCase__  :
   __UpperCAmelCase           =						()
   __UpperCAmelCase           =						True



   def  _UpperCamelCase		(    self     )				->     Tuple:
        """simple docstring"""





        _UpperCamelCase  :List[str]       =self.config_class

        # test default config
        _UpperCamelCase  :List[Any]       =config_class()
        self.assertIsNotNone(lowerCAmelCase__     )
        _UpperCamelCase  :List[str]       =["""stem"""] + [f'''stage{idx}''' for idx in range(1					,      len(config.depths     ) + 1     )]
        self.assertEqual(config.stage_names					,      lowerCAmelCase__     )
        self.assertTrue(set(config.out_features     ).issubset(set(config.stage_names     )     )     )

        # Test out_features and out_indices are correctly set
        # out_features and out_indices both None
        _UpperCamelCase  :Any       =config_class(out_features=lowerCAmelCase__					,      out_indices=lowerCAmelCase__     )
        self.assertEqual(config.out_features					,      [config.stage_names[-1]]     )
        self.assertEqual(config.out_indices					,      [len(config.stage_names     ) - 1]     )

        # out_features and out_indices both set
        _UpperCamelCase  :int       =config_class(out_features=["""stem""", """stage1"""]					,      out_indices=[0, 1]     )
        self.assertEqual(config.out_features					,      ["""stem""", """stage1"""]     )
        self.assertEqual(config.out_indices					,      [0, 1]     )

        # Only out_features set
        _UpperCamelCase  :Dict       =config_class(out_features=["""stage1""", """stage3"""]     )
        self.assertEqual(config.out_features					,      ["""stage1""", """stage3"""]     )
        self.assertEqual(config.out_indices					,      [1, 3]     )

        # Only out_indices set
        _UpperCamelCase  :Tuple       =config_class(out_indices=[0, 2]     )
        self.assertEqual(config.out_features					,      [config.stage_names[0], config.stage_names[2]]     )
        self.assertEqual(config.out_indices					,      [0, 2]     )

        # Error raised when out_indices do not correspond to out_features
        with self.assertRaises(lowerCAmelCase__     ):
             _UpperCamelCase  :List[Any]       =config_class(out_features=["""stage1""", """stage2"""]					,      out_indices=[0, 2]     )



   def  _UpperCamelCase		(    self     )				->     List[Any]:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :Optional[Any]       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _UpperCamelCase  :Union[str, Any]       =model_class(lowerCAmelCase__     )
             _UpperCamelCase  :Union[str, Any]       =inspect.signature(model.forward     )
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             _UpperCamelCase  :Tuple       =[*signature.parameters.keys()]
             _UpperCamelCase  :Any       =["""pixel_values"""]
             self.assertListEqual(arg_names[:1]					,      lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     int:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :List[str]       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _UpperCamelCase  :int       =model_class(lowerCAmelCase__     )
             self.assertEqual(len(model.channels     )					,      len(config.out_features     )     )
             _UpperCamelCase  :List[str]       =model.num_features
             _UpperCamelCase  :int       =[config.stage_names.index(lowerCAmelCase__     ) for feat in config.out_features]
             _UpperCamelCase  :List[str]       =[num_features[idx] for idx in out_indices]
             self.assertListEqual(model.channels					,      lowerCAmelCase__     )

             _UpperCamelCase  :Any       =copy.deepcopy(lowerCAmelCase__     )
             _UpperCamelCase  :List[Any]       =None
             _UpperCamelCase  :Optional[Any]       =model_class(lowerCAmelCase__     )
             self.assertEqual(len(model.channels     )					,      1     )
             self.assertListEqual(model.channels					,      [num_features[-1]]     )

             _UpperCamelCase  :Tuple       =copy.deepcopy(lowerCAmelCase__     )
             _UpperCamelCase  :int       =None
             _UpperCamelCase  :int       =model_class(lowerCAmelCase__     )
             self.assertEqual(len(model.channels     )					,      1     )
             self.assertListEqual(model.channels					,      [num_features[-1]]     )



   def  _UpperCamelCase		(    self     )				->     str:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :Any       =self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
             _UpperCamelCase  :List[Any]       =model_class(lowerCAmelCase__     )
             model.to(lowerCAmelCase__     )
             model.eval()
             _UpperCamelCase  :str       =model(**lowerCAmelCase__     )

             self.assertEqual(len(result.feature_maps     )					,      len(config.out_features     )     )
             self.assertEqual(len(model.channels     )					,      len(config.out_features     )     )
             self.assertEqual(len(result.feature_maps     )					,      len(config.out_indices     )     )
             self.assertEqual(len(model.channels     )					,      len(config.out_indices     )     )

             # Check output of last stage is taken if out_features=None, out_indices=None
             _UpperCamelCase  :Any       =copy.deepcopy(lowerCAmelCase__     )
             _UpperCamelCase  :List[Any]       =None
             _UpperCamelCase  :Dict       =model_class(lowerCAmelCase__     )
             model.to(lowerCAmelCase__     )
             model.eval()
             _UpperCamelCase  :str       =model(**lowerCAmelCase__     )

             self.assertEqual(len(result.feature_maps     )					,      1     )
             self.assertEqual(len(model.channels     )					,      1     )

             _UpperCamelCase  :str       =copy.deepcopy(lowerCAmelCase__     )
             _UpperCamelCase  :Dict       =None
             _UpperCamelCase  :Tuple       =model_class(lowerCAmelCase__     )
             model.to(lowerCAmelCase__     )
             model.eval()
             _UpperCamelCase  :Dict       =model(**lowerCAmelCase__     )

             self.assertEqual(len(result.feature_maps     )					,      1     )
             self.assertEqual(len(model.channels     )					,      1     )

             # Check backbone can be initialized with fresh weights
             _UpperCamelCase  :Any       =copy.deepcopy(lowerCAmelCase__     )
             _UpperCamelCase  :Optional[int]       =False
             _UpperCamelCase  :Any       =model_class(lowerCAmelCase__     )
             model.to(lowerCAmelCase__     )
             model.eval()
             _UpperCamelCase  :Optional[int]       =model(**lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     Optional[int]:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :Dict       =self.model_tester.prepare_config_and_inputs_for_common()

        for backbone_class in self.all_model_classes:
             _UpperCamelCase  :Optional[int]       =backbone_class(lowerCAmelCase__     )

             self.assertTrue(hasattr(lowerCAmelCase__					,      """backbone_type"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """stage_names"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """num_features"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """out_indices"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """out_features"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """out_feature_channels"""     )     )
             self.assertTrue(hasattr(lowerCAmelCase__					,      """channels"""     )     )

             self.assertIsInstance(backbone.backbone_type					,      lowerCAmelCase__     )
             # Verify num_features has been initialized in the backbone init
             self.assertIsNotNone(backbone.num_features     )
             self.assertTrue(len(backbone.channels     ) == len(backbone.out_indices     )     )
             self.assertTrue(len(backbone.stage_names     ) == len(backbone.num_features     )     )
             self.assertTrue(len(backbone.channels     ) <= len(backbone.num_features     )     )
             self.assertTrue(len(backbone.out_feature_channels     ) == len(backbone.stage_names     )     )




   def  _UpperCamelCase		(    self     )				->     Tuple:
        """simple docstring"""





        _UpperCamelCase       ,      _UpperCamelCase  :List[Any]       =self.model_tester.prepare_config_and_inputs_for_common()
        _UpperCamelCase  :Union[str, Any]       =inputs_dict["""pixel_values"""].shape[0]

        for backbone_class in self.all_model_classes:
             _UpperCamelCase  :str       =backbone_class(lowerCAmelCase__     )
             backbone.to(lowerCAmelCase__     )
             backbone.eval()

             _UpperCamelCase  :Any       =backbone(**lowerCAmelCase__     )

             # Test default outputs and verify feature maps
             self.assertIsInstance(outputs.feature_maps					,      lowerCAmelCase__     )
             self.assertTrue(len(outputs.feature_maps     ) == len(backbone.channels     )     )
             for feature_map, n_channels in zip(outputs.feature_maps					,      backbone.channels     ):
                  self.assertTrue(feature_map.shape[:2]					,      (batch_size, n_channels)     )
             self.assertIsNone(outputs.hidden_states     )
             self.assertIsNone(outputs.attentions     )

             # Test output_hidden_states=True
             _UpperCamelCase  :Any       =backbone(**lowerCAmelCase__					,      output_hidden_states=lowerCAmelCase__     )
             self.assertIsNotNone(outputs.hidden_states     )
             self.assertTrue(len(outputs.hidden_states     )					,      len(backbone.stage_names     )     )
             for hidden_state, n_channels in zip(outputs.hidden_states					,      backbone.channels     ):
                  self.assertTrue(hidden_state.shape[:2]					,      (batch_size, n_channels)     )

             # Test output_attentions=True
             if self.has_attentions:
                  _UpperCamelCase  :int       =backbone(**lowerCAmelCase__					,      output_attentions=lowerCAmelCase__     )
                  self.assertIsNotNone(outputs.attentions     )