

def       a__					(		UpperCAmelCase							:      str    ,			UpperCAmelCase							:      int      )  ->						str:
  UpperCAmelCase	:							list[list[str]]						=			[[] for _ in range(UpperCAmelCase      )]
  UpperCAmelCase	:							int						=			key - 1

  if key <= 0:
    raise ValueError('''Height of grid can\'t be 0 or negative'''      )
  if key == 1 or len(UpperCAmelCase      ) <= key:
    return input_string

  for position, character in enumerate(UpperCAmelCase      ):
    UpperCAmelCase	:							Optional[Any]						=			position % (lowest * 2)  # puts it in bounds
    UpperCAmelCase	:							Optional[Any]						=			min(UpperCAmelCase    ,			lowest * 2 - num      )  # creates zigzag pattern
    temp_grid[num].append(UpperCAmelCase      )
  UpperCAmelCase	:							Any						=			[''''''.join(UpperCAmelCase      ) for row in temp_grid]
  UpperCAmelCase	:							Union[str, Any]						=			''''''.join(UpperCAmelCase      )

  return output_string

def       a__					(		UpperCAmelCase							:      str    ,			UpperCAmelCase							:      int      )  ->						str:
  UpperCAmelCase	:							Tuple						=			[]
  UpperCAmelCase	:							Any						=			key - 1

  if key <= 0:
    raise ValueError('''Height of grid can\'t be 0 or negative'''      )
  if key == 1:
    return input_string

  UpperCAmelCase	:							list[list[str]]						=			[[] for _ in range(UpperCAmelCase      )]  # generates template
  for position in range(len(UpperCAmelCase      )      ):
    UpperCAmelCase	:							int						=			position % (lowest * 2)  # puts it in bounds
    UpperCAmelCase	:							Tuple						=			min(UpperCAmelCase    ,			lowest * 2 - num      )  # creates zigzag pattern
    temp_grid[num].append('''*'''      )

  UpperCAmelCase	:							Any						=			0
  for row in temp_grid:  # fills in the characters
    UpperCAmelCase	:							List[str]						=			input_string[counter : counter + len(UpperCAmelCase      )]
    grid.append(list(UpperCAmelCase      )      )
    counter += len(UpperCAmelCase      )

  UpperCAmelCase	:							Optional[Any]						=			''''''  # reads as zigzag
  for position in range(len(UpperCAmelCase      )      ):
    UpperCAmelCase	:							int						=			position % (lowest * 2)  # puts it in bounds
    UpperCAmelCase	:							List[str]						=			min(UpperCAmelCase    ,			lowest * 2 - num      )  # creates zigzag pattern
    output_string += grid[num][0]
    grid[num].pop(0      )
  return output_string

def       a__					(		UpperCAmelCase							:      str      )  ->						dict[int, str]:
  UpperCAmelCase	:							int						=			{}
  for key_guess in range(1    ,			len(UpperCAmelCase      )      ):  # tries every key
    UpperCAmelCase	:							List[Any]						=			decrypt(UpperCAmelCase    ,			UpperCAmelCase      )
  return results


if __name__ == "__main__":
     import doctest

     doctest.testmod()








import logging
import os

from .state import PartialState





class  __UpperCAmelCase					(	logging.LoggerAdapter						):



   @staticmethod
   def 	__magic_name__   (							__A							:					str						):
     UpperCAmelCase	:							Dict						=			PartialState()
     return not main_process_only or (main_process_only and state.is_main_process)





   def 	__magic_name__   (							self							:					Union[str, Any],		__A							:					Union[str, Any],		__A							:					Union[str, Any],		*__A							:					Optional[int],		**__A							:					Tuple						):
     if PartialState._shared_state == {}:
       raise RuntimeError(
           '''You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'''						)
     UpperCAmelCase	:							List[str]						=			kwargs.pop('''main_process_only''',		__A						)
     UpperCAmelCase	:							int						=			kwargs.pop('''in_order''',		__A						)

     if self.isEnabledFor(__A						):
       if self._should_log(__A						):
         UpperCAmelCase			,						UpperCAmelCase	:							Dict						=			self.process(__A,		__A						)
         self.logger.log(__A,		__A,		*__A,		**__A						)

       elif in_order:
         UpperCAmelCase	:							Dict						=			PartialState()
         for i in range(state.num_processes						):
           if i == state.process_index:
             UpperCAmelCase			,						UpperCAmelCase	:							Optional[int]						=			self.process(__A,		__A						)
             self.logger.log(__A,		__A,		*__A,		**__A						)
           state.wait_for_everyone()






def       a__					(		UpperCAmelCase							:      str    ,			UpperCAmelCase							:      str = None      )  ->						Dict:
  if log_level is None:
    UpperCAmelCase	:							Union[str, Any]						=			os.environ.get('''ACCELERATE_LOG_LEVEL'''    ,			UpperCAmelCase      )
  UpperCAmelCase	:							Tuple						=			logging.getLogger(UpperCAmelCase      )
  if log_level is not None:
    logger.setLevel(log_level.upper()      )
    logger.root.setLevel(log_level.upper()      )
  return MultiProcessAdapter(UpperCAmelCase    ,			{}      )





