



"""simple docstring"""






from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

lowerCAmelCase__        =				{'''UserAgent''': UserAgent().random}






def        snake_case_  (      A_					:		str						):


       '''simple docstring'''





       _lowerCamelCase						:				Tuple    			= script.contents[0]
       _lowerCamelCase						:				Optional[Any]    			= json.loads(data[data.find('''{"config"'''						) : -1]						)
       return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]






class        __snake_case       :




  def __init__( self     :						str						,					__lowerCAmelCase     :						List[Any]		):






         """simple docstring"""






         _lowerCamelCase						:				Union[str, Any]    			= f'''https://www.instagram.com/{username}/'''
         _lowerCamelCase						:				Optional[int]    			= self.get_json()




  def 						SCREAMING_SNAKE_CASE				( self     :						Dict		):






         """simple docstring"""






         _lowerCamelCase						:				str    			= requests.get(self.url						,					headers=__lowerCAmelCase		).text
         _lowerCamelCase						:				List[str]    			= BeautifulSoup(__lowerCAmelCase						,					'''html.parser'''		).find_all('''script'''		)
         try:
                return extract_user_profile(scripts[4]		)
         except (json.decoder.JSONDecodeError, KeyError):
                return extract_user_profile(scripts[3]		)




  def __repr__( self     :						Tuple		):






         """simple docstring"""






         return f'''{self.__class__.__name__}(\'{self.username}\')'''




  def __str__( self     :						Any		):






         """simple docstring"""






         return f'''{self.fullname} ({self.username}) is {self.biography}'''




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						str		):






         """simple docstring"""






         return self.user_data["username"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						List[str]		):






         """simple docstring"""






         return self.user_data["full_name"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						Optional[Any]		):






         """simple docstring"""






         return self.user_data["biography"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						int		):






         """simple docstring"""






         return self.user_data["business_email"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						List[str]		):






         """simple docstring"""






         return self.user_data["external_url"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						Union[str, Any]		):






         """simple docstring"""






         return self.user_data["edge_followed_by"]["count"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						str		):






         """simple docstring"""






         return self.user_data["edge_follow"]["count"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						Dict		):






         """simple docstring"""






         return self.user_data["edge_owner_to_timeline_media"]["count"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						Dict		):






         """simple docstring"""






         return self.user_data["profile_pic_url_hd"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						List[str]		):






         """simple docstring"""






         return self.user_data["is_verified"]




  @property
  def 						SCREAMING_SNAKE_CASE				( self     :						List[str]		):






         """simple docstring"""






         return self.user_data["is_private"]






def        snake_case_  (      A_					:		str = "github"						):


       '''simple docstring'''





       import os

       if os.environ.get('''CI'''						):
              return  # test failing on GitHub Actions
       _lowerCamelCase						:				List[Any]    			= InstagramUser(A_						)
       assert instagram_user.user_data
       assert isinstance(instagram_user.user_data,				A_						)
       assert instagram_user.username == username
       if username != "github":
              return
       assert instagram_user.fullname == "GitHub"
       assert instagram_user.biography == "Built for developers."
       assert instagram_user.number_of_posts > 1_50
       assert instagram_user.number_of_followers > 12_00_00
       assert instagram_user.number_of_followings > 15
       assert instagram_user.email == "support@github.com"
       assert instagram_user.website == "https://github.com/readme"
       assert instagram_user.profile_picture_url.startswith('''https://instagram.'''						)
       assert instagram_user.is_verified is True
       assert instagram_user.is_private is False


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   lowerCAmelCase__        =				InstagramUser('''github''')
   print(instagram_user)
   print(F"""{instagram_user.number_of_posts = }""")
   print(F"""{instagram_user.number_of_followers = }""")
   print(F"""{instagram_user.number_of_followings = }""")
   print(F"""{instagram_user.email = }""")
   print(F"""{instagram_user.website = }""")
   print(F"""{instagram_user.profile_picture_url = }""")
   print(F"""{instagram_user.is_verified = }""")
   print(F"""{instagram_user.is_private = }""")





'''simple docstring'''
import numpy as np
from PIL import Image


def        _lowerCAmelCase					(						_UpperCamelCase						:     np.ndarray							, _UpperCamelCase						:     int							, _UpperCamelCase						:     int				)      ->			np.ndarray:
     """simple docstring"""




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

     # compute the shape of the output matrix
     _SCREAMING_SNAKE_CASE							    =(arr.shape[0] - size) // stride + 1
     # initialize the output matrix with zeros of shape maxpool_shape
     _SCREAMING_SNAKE_CASE							    =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
               _SCREAMING_SNAKE_CASE							    =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
          _SCREAMING_SNAKE_CASE							    =0
          _SCREAMING_SNAKE_CASE							    =0

     return updated_arr


def        _lowerCAmelCase					(						_UpperCamelCase						:     np.ndarray							, _UpperCamelCase						:     int							, _UpperCamelCase						:     int				)      ->			np.ndarray:
     """simple docstring"""




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

     # compute the shape of the output matrix
     _SCREAMING_SNAKE_CASE							    =(arr.shape[0] - size) // stride + 1
     # initialize the output matrix with zeros of shape avgpool_shape
     _SCREAMING_SNAKE_CASE							    =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
               _SCREAMING_SNAKE_CASE							    =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
          _SCREAMING_SNAKE_CASE							    =0
          _SCREAMING_SNAKE_CASE							    =0

     return updated_arr


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

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

     # Loading the image
     lowerCamelCase :      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()
