code: 
  
  
  
  
  
  '''simple docstring'''
  
  from __future__ import annotations
  
  import unittest
  
  from transformers import AlbertConfig, is_tf_available
  from transformers.models.auto import get_values
  from transformers.testing_utils import require_tf, slow
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_tf_available():
         import tensorflow as tf
  
         from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
         from transformers.models.albert.modeling_tf_albert import (
             TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
             TFAlbertForMaskedLM,
             TFAlbertForMultipleChoice,
             TFAlbertForPreTraining,
             TFAlbertForQuestionAnswering,
             TFAlbertForSequenceClassification,
             TFAlbertForTokenClassification,
             TFAlbertModel,
         )
  
  
  class       a_  :
  
      '''simple docstring'''
  
  
      def __init__(	self				,	A				,	A=13				,	A=7				,	A=True				,	A=True				,	A=True				,	A=True				,	A=99				,	A=16				,	A=32				,	A=2				,	A=4				,	A=37				,	A="gelu"				,	A=0.1				,	A=0.1				,	A=512				,	A=16				,	A=2				,	A=0.02				,	A=3				,	A=4				,	A=None				,	)	->     Optional[Any]:
          _SCREAMING_SNAKE_CASE             =    parent
          _SCREAMING_SNAKE_CASE             =    13
          _SCREAMING_SNAKE_CASE             =    7
          _SCREAMING_SNAKE_CASE             =    True
          _SCREAMING_SNAKE_CASE             =    True
          _SCREAMING_SNAKE_CASE             =    True
          _SCREAMING_SNAKE_CASE             =    True
          _SCREAMING_SNAKE_CASE             =    99
          _SCREAMING_SNAKE_CASE             =    16
          _SCREAMING_SNAKE_CASE             =    32
          _SCREAMING_SNAKE_CASE             =    2
          _SCREAMING_SNAKE_CASE             =    4
          _SCREAMING_SNAKE_CASE             =    37
          _SCREAMING_SNAKE_CASE             =    """gelu"""
          _SCREAMING_SNAKE_CASE             =    0.1
          _SCREAMING_SNAKE_CASE             =    0.1
          _SCREAMING_SNAKE_CASE             =    512
          _SCREAMING_SNAKE_CASE             =    16
          _SCREAMING_SNAKE_CASE             =    2
          _SCREAMING_SNAKE_CASE             =    0.02
          _SCREAMING_SNAKE_CASE             =    3
          _SCREAMING_SNAKE_CASE             =    4
          _SCREAMING_SNAKE_CASE             =    None
  
  
      def     snake_case_(	self )	->     Union[str, Any]:
          _SCREAMING_SNAKE_CASE             =    ids_tensor([self.batch_size, self.seq_length]				,	self.vocab_size )
  
          _SCREAMING_SNAKE_CASE             =    None
          if self.use_input_mask:
              _SCREAMING_SNAKE_CASE             =    random_attention_mask([self.batch_size, self.seq_length] )
  
          _SCREAMING_SNAKE_CASE             =    None
          if self.use_token_type_ids:
              _SCREAMING_SNAKE_CASE             =    ids_tensor([self.batch_size, self.seq_length]				,	self.type_vocab_size )
  
          _SCREAMING_SNAKE_CASE             =    None
          _SCREAMING_SNAKE_CASE             =    None
          _SCREAMING_SNAKE_CASE             =    None
          if self.use_labels:
              _SCREAMING_SNAKE_CASE             =    ids_tensor([self.batch_size]				,	self.type_sequence_label_size )
              _SCREAMING_SNAKE_CASE             =    ids_tensor([self.batch_size, self.seq_length]				,	self.num_labels )
              _SCREAMING_SNAKE_CASE             =    ids_tensor([self.batch_size]				,	self.num_choices )
  
          _SCREAMING_SNAKE_CASE             =    AlbertConfig(
              vocab_size=self.vocab_size				,	hidden_size=self.hidden_size				,	embedding_size=self.embedding_size				,	num_hidden_layers=self.num_hidden_layers				,	num_attention_heads=self.num_attention_heads				,	intermediate_size=self.intermediate_size				,	hidden_act=self.hidden_act				,	hidden_dropout_prob=self.hidden_dropout_prob				,	attention_probs_dropout_prob=self.attention_probs_dropout_prob				,	max_position_embeddings=self.max_position_embeddings				,	type_vocab_size=self.type_vocab_size				,	initializer_range=self.initializer_range				,	)
  
          return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     int:
          _SCREAMING_SNAKE_CASE             =    TFAlbertModel(config=lowerCAmelCase_ )
          # inputs = {'input_ids': input_ids,
          #           'attention_mask': input_mask,
          #           'token_type_ids': token_type_ids}
          # sequence_output, pooled_output = model(**inputs)
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
  
          _SCREAMING_SNAKE_CASE             =    [input_ids, input_mask]
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
  
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
  
          self.parent.assertEqual(result.last_hidden_state.shape				,	(self.batch_size, self.seq_length, self.hidden_size) )
          self.parent.assertEqual(result.pooler_output.shape				,	(self.batch_size, self.hidden_size) )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     List[str]:
          _SCREAMING_SNAKE_CASE             =    self.num_labels
          _SCREAMING_SNAKE_CASE             =    TFAlbertForPreTraining(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertEqual(result.prediction_logits.shape				,	(self.batch_size, self.seq_length, self.vocab_size) )
          self.parent.assertEqual(result.sop_logits.shape				,	(self.batch_size, self.num_labels) )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     str:
          _SCREAMING_SNAKE_CASE             =    TFAlbertForMaskedLM(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertEqual(result.logits.shape				,	(self.batch_size, self.seq_length, self.vocab_size) )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     str:
          _SCREAMING_SNAKE_CASE             =    self.num_labels
          _SCREAMING_SNAKE_CASE             =    TFAlbertForSequenceClassification(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertEqual(result.logits.shape				,	(self.batch_size, self.num_labels) )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     str:
          _SCREAMING_SNAKE_CASE             =    TFAlbertForQuestionAnswering(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertEqual(result.start_logits.shape				,	(self.batch_size, self.seq_length) )
          self.parent.assertEqual(result.end_logits.shape				,	(self.batch_size, self.seq_length) )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     Any:
          _SCREAMING_SNAKE_CASE             =    self.num_choices
          _SCREAMING_SNAKE_CASE             =    TFAlbertForMultipleChoice(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    tf.tile(tf.expand_dims(lowerCAmelCase_				,	1 )				,	(1, self.num_choices, 1) )
          _SCREAMING_SNAKE_CASE             =    tf.tile(tf.expand_dims(lowerCAmelCase_				,	1 )				,	(1, self.num_choices, 1) )
          _SCREAMING_SNAKE_CASE             =    tf.tile(tf.expand_dims(lowerCAmelCase_				,	1 )				,	(1, self.num_choices, 1) )
          _SCREAMING_SNAKE_CASE             =    {
              """input_ids""": multiple_choice_inputs_ids,
              """attention_mask""": multiple_choice_input_mask,
              """token_type_ids""": multiple_choice_token_type_ids,
          }
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertListEqual(list(result["""logits"""].shape )				,	[self.batch_size, self.num_choices] )
  
  
      def     snake_case_(	self				,	A				,	A				,	A				,	A				,	A				,	A				,	A )	->     List[Any]:
          _SCREAMING_SNAKE_CASE             =    self.num_labels
          _SCREAMING_SNAKE_CASE             =    TFAlbertForTokenClassification(config=lowerCAmelCase_ )
          _SCREAMING_SNAKE_CASE             =    {
              """input_ids""": input_ids,
              """attention_mask""": input_mask,
              """token_type_ids""": token_type_ids,
          }
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )
          self.parent.assertListEqual(list(result["""logits"""].shape )				,	[self.batch_size, self.seq_length, self.num_labels] )
  
  
  
  
  
      def     snake_case_(	self )	->     str:
          _SCREAMING_SNAKE_CASE             =    self.prepare_config_and_inputs()
          (
              (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , (
              _SCREAMING_SNAKE_CASE
          )       , 
          )             =    config_and_inputs
          _SCREAMING_SNAKE_CASE             =    {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
          return config, inputs_dict
  
  
  
  
  @require_tf
  class       a_  (       lowerCAmelCase__   ,					lowerCAmelCase__   ,					unittest.TestCase ):
  
      '''simple docstring'''
      UpperCamelCase									=				(
          (
              TFAlbertModel,
              TFAlbertForPreTraining,
              TFAlbertForMaskedLM,
              TFAlbertForSequenceClassification,
              TFAlbertForQuestionAnswering,
              TFAlbertForTokenClassification,
              TFAlbertForMultipleChoice,
          )
          if is_tf_available()
          else ()
      )
      UpperCamelCase									=				(
          {
              """feature-extraction""": TFAlbertModel,
              """fill-mask""": TFAlbertForMaskedLM,
              """question-answering""": TFAlbertForQuestionAnswering,
              """text-classification""": TFAlbertForSequenceClassification,
              """token-classification""": TFAlbertForTokenClassification,
              """zero-shot""": TFAlbertForSequenceClassification,
          }
          if is_tf_available()
          else {}
      )
      UpperCamelCase									=				False
      UpperCamelCase									=				False
  
  
      def     snake_case_(	self				,	A				,	A				,	A=False )	->     int:
          _SCREAMING_SNAKE_CASE             =    super()._prepare_for_class(lowerCAmelCase_				,	lowerCAmelCase_				,	return_labels=lowerCAmelCase_ )
  
          if return_labels:
              if model_class in get_values(lowerCAmelCase_ ):
                  _SCREAMING_SNAKE_CASE             =    tf.zeros(self.model_tester.batch_size				,	dtype=tf.intaa )
  
          return inputs_dict
  
  
      def     snake_case_(	self )	->     Optional[Any]:
          _SCREAMING_SNAKE_CASE             =    TFAlbertModelTester(self )
          _SCREAMING_SNAKE_CASE             =    ConfigTester(self				,	config_class=lowerCAmelCase_				,	hidden_size=37 )
  
  
      def     snake_case_(	self )	->     Dict:
          self.config_tester.run_common_tests()
  
  
      def     snake_case_(	self )	->     Tuple:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_model(*lowerCAmelCase_ )
  
  
      def     snake_case_(	self )	->     str:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_for_pretraining(*lowerCAmelCase_ )
  
  
      def     snake_case_(	self )	->     List[str]:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_for_masked_lm(*lowerCAmelCase_ )
  
  
      def     snake_case_(	self )	->     Tuple:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_for_multiple_choice(*lowerCAmelCase_ )
  
  
      def     snake_case_(	self )	->     Dict:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_for_sequence_classification(*lowerCAmelCase_ )
  
  
      def     snake_case_(	self )	->     Union[str, Any]:
          _SCREAMING_SNAKE_CASE             =    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_albert_for_question_answering(*lowerCAmelCase_ )
  
  
  
  
  
      @slow
      def     snake_case_(	self )	->     List[str]:
  
  
  
  
  
  
          for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _SCREAMING_SNAKE_CASE             =    TFAlbertModel.from_pretrained(lowerCAmelCase_ )
              self.assertIsNotNone(lowerCAmelCase_ )
  
  
  
  
  @require_tf
  class       a_  (       unittest.TestCase ):
  
      '''simple docstring'''
  
  
      @slow
      def     snake_case_(	self )	->     Union[str, Any]:
          _SCREAMING_SNAKE_CASE             =    TFAlbertForPreTraining.from_pretrained("""albert-base-v2""" )
          _SCREAMING_SNAKE_CASE             =    tf.constant([[0, 1, 2, 3, 4, 5]] )
          _SCREAMING_SNAKE_CASE             =    model(lowerCAmelCase_ )[0]
  
          _SCREAMING_SNAKE_CASE             =    [1, 6, 3_0000]
          self.assertEqual(output.shape				,	lowerCAmelCase_ )
  
          _SCREAMING_SNAKE_CASE             =    tf.constant(
              [
                  [
                      [4.59_5668, 0.7446_2754, -1.81_8147],
                      [4.595_4347, 0.745_4184, -1.818_8258],
                      [4.595_4905, 0.744_8235, -1.818_2316],
                  ]
              ] )
          tf.debugging.assert_near(output[:, :3, :3]				,	lowerCAmelCase_				,	atol=1e-4 )
  
  
  
  
style_context: 
  
  
  
  
  
  '''simple docstring'''
  
  def lowerCamelCase		(  __lowerCamelCase				:					float      , __lowerCamelCase				:					float      , __lowerCamelCase				:					float					)		->list[int]:
      if hue < 0 or hue > 360:
          raise Exception("""hue should be between 0 and 360"""					)
  
      if saturation < 0 or saturation > 1:
          raise Exception("""saturation should be between 0 and 1"""					)
  
      if value < 0 or value > 1:
          raise Exception("""value should be between 0 and 1"""					)
  
      _SCREAMING_SNAKE_CASE             =    value * saturation
      _SCREAMING_SNAKE_CASE             =    hue / 60
      _SCREAMING_SNAKE_CASE             =    chroma * (1 - abs(hue_section % 2 - 1					))
      _SCREAMING_SNAKE_CASE             =    value - chroma
  
      if hue_section >= 0 and hue_section <= 1:
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
      elif hue_section > 1 and hue_section <= 2:
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
      elif hue_section > 2 and hue_section <= 3:
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
      elif hue_section > 3 and hue_section <= 4:
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
      elif hue_section > 4 and hue_section <= 5:
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
      else:
          _SCREAMING_SNAKE_CASE             =    round(255 * (chroma + match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (match_value)					)
          _SCREAMING_SNAKE_CASE             =    round(255 * (second_largest_component + match_value)					)
  
      return [red, green, blue]
  
  
  
  
  
  def lowerCamelCase		(  __lowerCamelCase				:					int      , __lowerCamelCase				:					int      , __lowerCamelCase				:					int					)		->list[float]:
      if red < 0 or red > 255:
          raise Exception("""red should be between 0 and 255"""					)
  
      if green < 0 or green > 255:
          raise Exception("""green should be between 0 and 255"""					)
  
      if blue < 0 or blue > 255:
          raise Exception("""blue should be between 0 and 255"""					)
  
      _SCREAMING_SNAKE_CASE             =    red / 255
      _SCREAMING_SNAKE_CASE             =    green / 255
      _SCREAMING_SNAKE_CASE             =    blue / 255
      _SCREAMING_SNAKE_CASE             =    max(__lowerCamelCase      , __lowerCamelCase      , __lowerCamelCase					)
      _SCREAMING_SNAKE_CASE             =    value - min(__lowerCamelCase      , __lowerCamelCase      , __lowerCamelCase					)
      _SCREAMING_SNAKE_CASE             =    0 if value == 0 else chroma / value
  
      if chroma == 0:
          _SCREAMING_SNAKE_CASE             =    0.0
      elif value == float_red:
          _SCREAMING_SNAKE_CASE             =    60 * (0 + (float_green - float_blue) / chroma)
      elif value == float_green:
          _SCREAMING_SNAKE_CASE             =    60 * (2 + (float_blue - float_red) / chroma)
      else:
          _SCREAMING_SNAKE_CASE             =    60 * (4 + (float_red - float_green) / chroma)
  
      _SCREAMING_SNAKE_CASE             =    (hue + 360) % 360
  
      return [hue, saturation, value]
  
  
  
  
  
  
  def lowerCamelCase		(  __lowerCamelCase				:					list[float]      , __lowerCamelCase				:					list[float]					)		->bool:
      _SCREAMING_SNAKE_CASE             =    abs(hsv_a[0] - hsv_a[0]					) < 0.2
      _SCREAMING_SNAKE_CASE             =    abs(hsv_a[1] - hsv_a[1]					) < 0.002
      _SCREAMING_SNAKE_CASE             =    abs(hsv_a[2] - hsv_a[2]					) < 0.002
  
      return check_hue and check_saturation and check_value
  
  
  
  