






"""simple docstring"""







import unittest

from transformers import AlbertTokenizer, AlbertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


_UpperCamelCase					      =  get_tests_dir("""fixtures/spiece.model""")







@require_sentencepiece
@require_tokenizers
class  lowerCamelCase__ (	snake_case   ,					unittest.TestCase			):
    SCREAMING_SNAKE_CASE		=      AlbertTokenizer
    SCREAMING_SNAKE_CASE		=      AlbertTokenizerFast
    SCREAMING_SNAKE_CASE		=      True
    SCREAMING_SNAKE_CASE		=      True
    SCREAMING_SNAKE_CASE		=      True






    def     _UpperCamelCase							(			self ):
          super().setUp()

          # We have a SentencePiece fixture for testing
          UpperCAmelCase          =	AlbertTokenizer(lowerCamelCase_ )
          tokenizer.save_pretrained(self.tmpdirname )






    def     _UpperCamelCase							(			self     ,A ):
          UpperCAmelCase          =	"""this is a test"""
          UpperCAmelCase          =	"""this is a test"""
          return input_text, output_text






    def     _UpperCamelCase							(			self ):
          UpperCAmelCase          =	"""<pad>"""
          UpperCAmelCase          =	0

          self.assertEqual(self.get_tokenizer()._convert_token_to_id(lowerCamelCase_ )     ,lowerCamelCase_ )
          self.assertEqual(self.get_tokenizer()._convert_id_to_token(lowerCamelCase_ )     ,lowerCamelCase_ )






    def     _UpperCamelCase							(			self ):
          UpperCAmelCase          =	list(self.get_tokenizer().get_vocab().keys() )

          self.assertEqual(vocab_keys[0]     ,"""<pad>""" )
          self.assertEqual(vocab_keys[1]     ,"""<unk>""" )
          self.assertEqual(vocab_keys[-1]     ,"""▁eloquent""" )
          self.assertEqual(len(lowerCamelCase_ )     ,30_000 )






    def     _UpperCamelCase							(			self ):
          self.assertEqual(self.get_tokenizer().vocab_size     ,30_000 )






    def     _UpperCamelCase							(			self ):
          if not self.test_rust_tokenizer:
                return

          UpperCAmelCase          =	self.get_tokenizer()
          UpperCAmelCase          =	self.get_rust_tokenizer()

          UpperCAmelCase          =	"""I was born in 92000, and this is falsé."""

          UpperCAmelCase          =	tokenizer.tokenize(lowerCamelCase_ )
          UpperCAmelCase          =	rust_tokenizer.tokenize(lowerCamelCase_ )
          self.assertListEqual(lowerCamelCase_     ,lowerCamelCase_ )

          UpperCAmelCase          =	tokenizer.encode(lowerCamelCase_     ,add_special_tokens=lowerCamelCase_ )
          UpperCAmelCase          =	rust_tokenizer.encode(lowerCamelCase_     ,add_special_tokens=lowerCamelCase_ )
          self.assertListEqual(lowerCamelCase_     ,lowerCamelCase_ )

          UpperCAmelCase          =	self.get_rust_tokenizer()
          UpperCAmelCase          =	tokenizer.encode(lowerCamelCase_ )
          UpperCAmelCase          =	rust_tokenizer.encode(lowerCamelCase_ )
          self.assertListEqual(lowerCamelCase_     ,lowerCamelCase_ )






    def     _UpperCamelCase							(			self ):
          UpperCAmelCase          =	AlbertTokenizer(lowerCamelCase_     ,keep_accents=lowerCamelCase_ )

          UpperCAmelCase          =	tokenizer.tokenize("""This is a test""" )
          self.assertListEqual(lowerCamelCase_     ,["""▁this""", """▁is""", """▁a""", """▁test"""] )

          self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase_ )     ,[48, 25, 21, 1_289] )

          UpperCAmelCase          =	tokenizer.tokenize("""I was born in 92000, and this is falsé.""" )
          self.assertListEqual(
              lowerCamelCase_     ,["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """é""", """."""] )
          UpperCAmelCase          =	tokenizer.convert_tokens_to_ids(lowerCamelCase_ )
          self.assertListEqual(lowerCamelCase_     ,[31, 23, 386, 19, 561, 3_050, 15, 17, 48, 25, 8_256, 18, 1, 9] )

          UpperCAmelCase          =	tokenizer.convert_ids_to_tokens(lowerCamelCase_ )
          self.assertListEqual(
              lowerCamelCase_     ,["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """."""]     ,)






    def     _UpperCamelCase							(			self ):
          UpperCAmelCase          =	AlbertTokenizer(lowerCamelCase_ )

          UpperCAmelCase          =	tokenizer.encode("""sequence builders""" )
          UpperCAmelCase          =	tokenizer.encode("""multi-sequence build""" )

          UpperCAmelCase          =	tokenizer.build_inputs_with_special_tokens(lowerCamelCase_ )
          UpperCAmelCase          =	tokenizer.build_inputs_with_special_tokens(lowerCamelCase_     ,lowerCamelCase_ )

          assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
          assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
              tokenizer.sep_token_id
          ]






    @slow
    def     _UpperCamelCase							(			self ):
          # fmt: off
          UpperCAmelCase          =	{"""attention_mask""": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], """input_ids""": [[2, 21_970, 13, 5, 6_092, 167, 28, 7_103, 2_153, 673, 8, 7_028, 12_051, 18, 17, 7_103, 2_153, 673, 8, 3_515, 18_684, 8, 4_461, 6, 1_927, 297, 8, 12_060, 2_607, 18, 13, 5, 4_461, 15, 10_538, 38, 8, 135, 15, 822, 58, 15, 993, 10_363, 15, 1_460, 8_005, 4_461, 15, 993, 255, 2_328, 9, 9, 9, 6, 26, 1_112, 816, 3_260, 13, 5, 103, 2_377, 6, 17, 1_112, 816, 2_782, 13, 5, 103, 10_641, 6, 29, 84, 2_512, 2_430, 782, 18_684, 2_761, 19, 808, 2_430, 2_556, 17, 855, 1_480, 9_477, 4_091, 128, 11_712, 15, 7_103, 2_153, 673, 17, 24_883, 9_990, 9, 3], [2, 11_502, 25, 1_006, 20, 782, 8, 11_809, 855, 1_732, 19_393, 18_667, 37, 367, 21_018, 69, 1_854, 34, 11_860, 19_124, 27, 156, 225, 17, 193, 4_141, 19, 65, 9_124, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 14, 2_231, 886, 2_385, 17_659, 84, 14, 16_792, 1_952, 9, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
          # fmt: on

          self.tokenizer_integration_test_util(
              expected_encoding=lowerCamelCase_     ,model_name="""albert-base-v2"""     ,revision="""6b6560eaf5ff2e250b00c50f380c5389a9c2d82e"""     ,)











"""simple docstring"""







from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

_UpperCamelCase					      =  {"""UserAgent""": UserAgent().random}

def _a			(		_snake_case							):







      """simple docstring"""






      UpperCAmelCase          =	script.contents[0]
      UpperCAmelCase          =	json.loads(data[data.find("""{\"config\""""							) : -1]							)
      return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]







class  lowerCamelCase__ :






    def __init__(			self     ,A ):
          UpperCAmelCase          =	F'''https://www.instagram.com/{username}/'''
          UpperCAmelCase          =	self.get_json()






    def     _UpperCamelCase							(			self ):
          UpperCAmelCase          =	requests.get(self.url     ,headers=A ).text
          UpperCAmelCase          =	BeautifulSoup(A     ,"""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 ):
          return F'''{self.__class__.__name__}(\'{self.username}\')'''






    def __str__(			self ):
          return F'''{self.fullname} ({self.username}) is {self.biography}'''






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["username"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["full_name"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["biography"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["business_email"]






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






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






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["edge_follow"]["count"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["edge_owner_to_timeline_media"]["count"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["profile_pic_url_hd"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["is_verified"]






    @property
    def     _UpperCamelCase							(			self ):
          return self.user_data["is_private"]







def _a			(		_snake_case = "github"							):







      """simple docstring"""






      import os

      if os.environ.get("""CI"""							):
            return  # test failing on GitHub Actions
      UpperCAmelCase          =	InstagramUser(_snake_case							)
      assert instagram_user.user_data
      assert isinstance(instagram_user.user_data				,	_snake_case							)
      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 > 12_0000
      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()
  _UpperCamelCase					      =  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 = }""")



