

def     lowerCAmelCase__							(		SCREAMING_SNAKE_CASE_:							Optional[Any]					)	->					Dict:




				'''simple docstring'''





				A__						=	[]
				A__						=	[]
				A__						=	{
				    "^": 3,
				    "*": 2,
				    "/": 2,
				    "%": 2,
				    "+": 1,
				    "-": 1,
				}  # Priority of each operator
				A__						=	len(SCREAMING_SNAKE_CASE_					) if (len(SCREAMING_SNAKE_CASE_					) > 7) else 7

				# Print table header for output
				print(
				    "Symbol".center(8					)		,				"Stack".center(SCREAMING_SNAKE_CASE_					)		,				"Postfix".center(SCREAMING_SNAKE_CASE_					)		,				sep=" | "		,				)
				print("-" * (print_width * 3 + 7)					)

				for x in infix:
								if x.isalpha() or x.isdigit():
												post_fix.append(SCREAMING_SNAKE_CASE_					)  # if x is Alphabet / Digit, add it to Postfix
								elif x == "(":
												stack.append(SCREAMING_SNAKE_CASE_					)  # if x is "(" push to Stack
								elif x == ")":  # if x is ")" pop stack until "(" is encountered
												while stack[-1] != "(":
																post_fix.append(stack.pop()					)  # Pop stack & add the content to Postfix
												stack.pop()
								else:
												if len(SCREAMING_SNAKE_CASE_					) == 0:
																stack.append(SCREAMING_SNAKE_CASE_					)  # If stack is empty, push x to stack
												else:  # while priority of x is not > priority of element in the stack
																while len(SCREAMING_SNAKE_CASE_					) > 0 and priority[x] <= priority[stack[-1]]:
																				post_fix.append(stack.pop()					)  # pop stack & add to Postfix
																stack.append(SCREAMING_SNAKE_CASE_					)  # push x to stack

								print(
								    x.center(8					)		,				("".join(SCREAMING_SNAKE_CASE_					)).ljust(SCREAMING_SNAKE_CASE_					)		,				("".join(SCREAMING_SNAKE_CASE_					)).ljust(SCREAMING_SNAKE_CASE_					)		,				sep=" | "		,				)  # Output in tabular format

				while len(SCREAMING_SNAKE_CASE_					) > 0:  # while stack is not empty
								post_fix.append(stack.pop()					)  # pop stack & add to Postfix
								print(
								    " ".center(8					)		,				("".join(SCREAMING_SNAKE_CASE_					)).ljust(SCREAMING_SNAKE_CASE_					)		,				("".join(SCREAMING_SNAKE_CASE_					)).ljust(SCREAMING_SNAKE_CASE_					)		,				sep=" | "		,				)  # Output in tabular format

				return "".join(SCREAMING_SNAKE_CASE_					)  # return Postfix as str



def     lowerCAmelCase__							(		SCREAMING_SNAKE_CASE_:							Tuple					)	->					List[str]:




				'''simple docstring'''





				A__						=	list(infix[::-1]					)  # reverse the infix equation

				for i in range(len(SCREAMING_SNAKE_CASE_					)					):
								if infix[i] == "(":
												A__						=	")"  # change "(" to ")"
								elif infix[i] == ")":
												A__						=	"("  # change ")" to "("

				return (infix_2_postfix("".join(SCREAMING_SNAKE_CASE_					)					))[
				    ::-1
				]  # call infix_2_postfix on Infix, return reverse of Postfix


if __name__ == "__main__":
	lowerCAmelCase__		      =       input("""\nEnter an Infix Equation = """)  # Input an Infix equation
	lowerCAmelCase__		      =       """""".join(Infix.split())  # Remove spaces from the input
	print("""\n\t""", Infix, """(Infix) -> """, infix_2_prefix(Infix), """(Prefix)""")








import numpy as np
from PIL import Image



def _a				(	lowerCamelCase:   np.ndarray					,				lowerCamelCase:   int					,				lowerCamelCase:   int )	->						np.ndarray:







      '''simple docstring'''






      __A          =				np.array(lowerCamelCase )
      if arr.shape[0] != arr.shape[1]:
            raise ValueError('''The input array is not a square matrix''' )
      __A          =				0
      __A          =				0
      __A          =				0
      __A          =				0

      # compute the shape of the output matrix
      __A          =				(arr.shape[0] - size) // stride + 1
      # initialize the output matrix with zeros of shape maxpool_shape
      __A          =				np.zeros((maxpool_shape, maxpool_shape) )

      while i < arr.shape[0]:
            if i + size > arr.shape[0]:
                  # if the end of the matrix is reached, break
                  break
            while j < arr.shape[1]:
                  # if the end of the matrix is reached, break
                  if j + size > arr.shape[1]:
                        break
                  # compute the maximum of the pooling matrix
                  __A          =				np.max(arr[i : i + size, j : j + size] )
                  # shift the pooling matrix by stride of column pixels
                  j += stride
                  mat_j += 1

            # shift the pooling matrix by stride of row pixels
            i += stride
            mat_i += 1

            # reset the column index to 0
            __A          =				0
            __A          =				0

      return updated_arr



def _a				(	lowerCamelCase:   np.ndarray					,				lowerCamelCase:   int					,				lowerCamelCase:   int )	->						np.ndarray:







      '''simple docstring'''






      __A          =				np.array(lowerCamelCase )
      if arr.shape[0] != arr.shape[1]:
            raise ValueError('''The input array is not a square matrix''' )
      __A          =				0
      __A          =				0
      __A          =				0
      __A          =				0

      # compute the shape of the output matrix
      __A          =				(arr.shape[0] - size) // stride + 1
      # initialize the output matrix with zeros of shape avgpool_shape
      __A          =				np.zeros((avgpool_shape, avgpool_shape) )

      while i < arr.shape[0]:
            # if the end of the matrix is reached, break
            if i + size > arr.shape[0]:
                  break
            while j < arr.shape[1]:
                  # if the end of the matrix is reached, break
                  if j + size > arr.shape[1]:
                        break
                  # compute the average of the pooling matrix
                  __A          =				int(np.average(arr[i : i + size, j : j + size] ) )
                  # shift the pooling matrix by stride of column pixels
                  j += stride
                  mat_j += 1

            # shift the pooling matrix by stride of row pixels
            i += stride
            mat_i += 1
            # reset the column index to 0
            __A          =				0
            __A          =				0

      return updated_arr


# Main Function
if __name__ == "__main__":
       from doctest import testmod

       testmod(name='avgpooling', verbose=True)

       # Loading the image
       snake_case__					:							Optional[Any]													=     Image.open('path_to_image')

       # Converting the image to numpy array and maxpooling, displaying the result
       # Ensure that the image is a square matrix

       Image.fromarray(maxpooling(np.array(image), size=3, stride=2)).show()

       # Converting the image to numpy array and averagepooling, displaying the result
       # Ensure that the image is a square matrix

       Image.fromarray(avgpooling(np.array(image), size=3, stride=2)).show()





