

import numpy as np
from PIL import Image
def      _lowerCAmelCase(	__A   ,       __A   ,       __A			):
  UpperCAmelCase					      =  np.array(__A			)
  if arr.shape[0] != arr.shape[1]:
    raise ValueError("The input array is not a square matrix"			)
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0

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

  return updated_arr
def      _lowerCAmelCase(	__A   ,       __A   ,       __A			):
  UpperCAmelCase					      =  np.array(__A			)
  if arr.shape[0] != arr.shape[1]:
    raise ValueError("The input array is not a square matrix"			)
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  0

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

  return updated_arr


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

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

      # Loading the image
      lowerCAmelCase__       = 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()






from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

lowerCAmelCase__       = {"UserAgent": UserAgent().random}
def      _lowerCAmelCase(	__A			):
  UpperCAmelCase					      =  script.contents[0]
  UpperCAmelCase					      =  json.loads(data[data.find("{\"config\""			) : -1]			)
  return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]






class 						__magic_name__    :


 def __init__(						self		: Optional[Any]			,						lowerCAmelCase__		: Optional[int]    )    ->      Any:
   UpperCAmelCase					      =  f"https://www.instagram.com/{username}/"
   UpperCAmelCase					      =  self.get_json()


 def _UpperCamelCase	(						self		: List[str]    )    ->      dict:
   UpperCAmelCase					      =  requests.get(self.url			,						headers=lowerCAmelCase__    ).text
   UpperCAmelCase					      =  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    )    ->      str:
   return f"{self.__class__.__name__}('{self.username}')"


 def __str__(						self		: Optional[int]    )    ->      str:
   return f"{self.fullname} ({self.username}) is {self.biography}"


 @property
 def _UpperCamelCase	(						self		: Any    )    ->      str:
   return self.user_data["username"]


 @property
 def _UpperCamelCase	(						self		: List[Any]    )    ->      str:
   return self.user_data["full_name"]


 @property
 def _UpperCamelCase	(						self		: List[str]    )    ->      str:
   return self.user_data["biography"]


 @property
 def _UpperCamelCase	(						self		: Optional[int]    )    ->      str:
   return self.user_data["business_email"]


 @property
 def _UpperCamelCase	(						self		: str    )    ->      str:
   return self.user_data["external_url"]


 @property
 def _UpperCamelCase	(						self		: int    )    ->      int:
   return self.user_data["edge_followed_by"]["count"]


 @property
 def _UpperCamelCase	(						self		: List[Any]    )    ->      int:
   return self.user_data["edge_follow"]["count"]


 @property
 def _UpperCamelCase	(						self		: List[str]    )    ->      int:
   return self.user_data["edge_owner_to_timeline_media"]["count"]


 @property
 def _UpperCamelCase	(						self		: Tuple    )    ->      str:
   return self.user_data["profile_pic_url_hd"]


 @property
 def _UpperCamelCase	(						self		: Optional[int]    )    ->      bool:
   return self.user_data["is_verified"]


 @property
 def _UpperCamelCase	(						self		: Optional[Any]    )    ->      bool:
   return self.user_data["is_private"]

def      _lowerCAmelCase(	__A = "github"			):
  import os

  if os.environ.get("CI"			):
    return  # test failing on GitHub Actions
  UpperCAmelCase					      =  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 > 150
  assert instagram_user.number_of_followers > 120000
  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 = }")



