






"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


_UpperCamelCase   :						List[Any]     						= {
    """configuration_sam""": [
        """SAM_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SamConfig""",
        """SamMaskDecoderConfig""",
        """SamPromptEncoderConfig""",
        """SamVisionConfig""",
    ],
    """processing_sam""": ["""SamProcessor"""],
}


try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase   :						Tuple     						= [
       """SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """SamModel""",
       """SamPreTrainedModel""",
   ]
try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase   :						Optional[Any]     						= [
       """TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """TFSamModel""",
       """TFSamPreTrainedModel""",
   ]
try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase   :						int     						= ["""SamImageProcessor"""]


if TYPE_CHECKING:
   from .configuration_sam import (
       SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
       SamConfig,
       SamMaskDecoderConfig,
       SamPromptEncoderConfig,
       SamVisionConfig,
   )
   from .processing_sam import SamProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_sam import SamImageProcessor

else:
   import sys

   _UpperCamelCase   :						int     						= _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)













"""simple docstring"""


from string import ascii_uppercase




def 				a (     UpperCamelCase_							:				str     ,	UpperCamelCase_							:				str     ,	UpperCamelCase_							:				bool = False     ,	UpperCamelCase_							:				str = ascii_uppercase		)  ->		str:
 __A	:       List[str]       =	keyword.upper()
 __A	:       str       =	plaintext.upper()
 __A	:       int       =	set(UpperCamelCase_		)

 # create a list of unique characters in the keyword - their order matters
 # it determines how we will map plaintext characters to the ciphertext
 __A	:       int       =	[]
 for char in keyword:
  if char in alphabet_set and char not in unique_chars:
   unique_chars.append(UpperCamelCase_		)
    # the number of those unique characters will determine the number of rows
 __A	:       Any       =	len(UpperCamelCase_		)

 # create a shifted version of the alphabet
 __A	:       str       =	unique_chars + [
     char for char in alphabet if char not in unique_chars
 ]

 # create a modified alphabet by splitting the shifted alphabet into rows
 __A	:       int       =	[
     shifted_alphabet[k : k + num_unique_chars_in_keyword]
     for k in range(0     ,	2_6     ,	UpperCamelCase_		)
 ]

 # map the alphabet characters to the modified alphabet characters
 # going 'vertically' through the modified alphabet - consider columns first
 __A	:       Any       =	{}
 __A	:       Union[str, Any]       =	0
 for column in range(UpperCamelCase_		):
  for row in modified_alphabet:
   # if current row (the last one) is too short, break out of loop
   if len(UpperCamelCase_		) <= column:
    break

   # map current letter to letter in modified alphabet
   __A	:       str       =	row[column]
   letter_index += 1

 if verbose:
  print(UpperCamelCase_		)
 # create the encrypted text by mapping the plaintext to the modified alphabet
 return "".join(mapping[char] if char in mapping else char for char in plaintext		)


if __name__ == "__main__":
   # example use
   print(mixed_keyword("""college""", """UNIVERSITY"""))





