


"""simple docstring"""







import os
import tempfile
import unittest

from transformers import NezhaConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch

 from transformers import (
     MODEL_FOR_PRETRAINING_MAPPING,
     NezhaForMaskedLM,
     NezhaForMultipleChoice,
     NezhaForNextSentencePrediction,
     NezhaForPreTraining,
     NezhaForQuestionAnswering,
     NezhaForSequenceClassification,
     NezhaForTokenClassification,
     NezhaModel,
 )
 from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST






class 						_A  :







    """simple docstring"""




    def __init__( self    :   List[Any]    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   Union[str, Any]=13    ,			__UpperCAmelCase    :   Tuple=7    ,			__UpperCAmelCase    :   Union[str, Any]=True    ,			__UpperCAmelCase    :   str=True    ,			__UpperCAmelCase    :   int=True    ,			__UpperCAmelCase    :   List[str]=True    ,			__UpperCAmelCase    :   Tuple=99    ,			__UpperCAmelCase    :   List[str]=32    ,			__UpperCAmelCase    :   List[Any]=5    ,			__UpperCAmelCase    :   Dict=4    ,			__UpperCAmelCase    :   str=37    ,			__UpperCAmelCase    :   Optional[int]="gelu"    ,			__UpperCAmelCase    :   Tuple=0.1    ,			__UpperCAmelCase    :   Optional[int]=0.1    ,			__UpperCAmelCase    :   Tuple=128    ,			__UpperCAmelCase    :   List[str]=32    ,			__UpperCAmelCase    :   Optional[Any]=16    ,			__UpperCAmelCase    :   List[Any]=2    ,			__UpperCAmelCase    :   str=0.02    ,			__UpperCAmelCase    :   Tuple=3    ,			__UpperCAmelCase    :   Tuple=4    ,			__UpperCAmelCase    :   Any=None    ,			):
      a						:		Optional[int]											=      parent
      a						:		Tuple											=      batch_size
      a						:		Any											=      seq_length
      a						:		Union[str, Any]											=      is_training
      a						:		Dict											=      use_input_mask
      a						:		Any											=      use_token_type_ids
      a						:		int											=      use_labels
      a						:		int											=      vocab_size
      a						:		Any											=      hidden_size
      a						:		List[str]											=      num_hidden_layers
      a						:		Optional[int]											=      num_attention_heads
      a						:		Optional[Any]											=      intermediate_size
      a						:		int											=      hidden_act
      a						:		Optional[int]											=      hidden_dropout_prob
      a						:		Tuple											=      attention_probs_dropout_prob
      a						:		Dict											=      max_position_embeddings
      a						:		Optional[int]											=      type_vocab_size
      a						:		Union[str, Any]											=      type_sequence_label_size
      a						:		Optional[Any]											=      initializer_range
      a						:		Dict											=      num_labels
      a						:		int											=      num_choices
      a						:		List[Any]											=      scope






    def      __snake_case							( self    :   Optional[int]):
      a						:		Dict											=      ids_tensor([self.batch_size, self.seq_length]    ,			self.vocab_size)

      a						:		Tuple											=      None
      if self.use_input_mask:
        a						:		str											=      random_attention_mask([self.batch_size, self.seq_length])

      a						:		str											=      None
      if self.use_token_type_ids:
        a						:		str											=      ids_tensor([self.batch_size, self.seq_length]    ,			self.type_vocab_size)

      a						:		List[Any]											=      None
      a						:		int											=      None
      a						:		Optional[Any]											=      None
      if self.use_labels:
        a						:		int											=      ids_tensor([self.batch_size]    ,			self.type_sequence_label_size)
        a						:		Optional[Any]											=      ids_tensor([self.batch_size, self.seq_length]    ,			self.num_labels)
        a						:		int											=      ids_tensor([self.batch_size]    ,			self.num_choices)

      a						:		Optional[Any]											=      self.get_config()

      return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






    def      __snake_case							( self    :   str):
      return NezhaConfig(
          vocab_size=self.vocab_size    ,			hidden_size=self.hidden_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    ,			is_decoder=lowerCAmelCase_    ,			initializer_range=self.initializer_range    ,			)






    def      __snake_case							( self    :   Dict):
      (
          (
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		  
      )						:		Dict											=      self.prepare_config_and_inputs()

      a						:		List[str]											=      True
      a						:		int											=      floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
      a						:		Any											=      ids_tensor([self.batch_size, self.seq_length]    ,			vocab_size=2)

      return (
          config,
          input_ids,
          token_type_ids,
          input_mask,
          sequence_labels,
          token_labels,
          choice_labels,
          encoder_hidden_states,
          encoder_attention_mask,
      )






    def      __snake_case							( self    :   Union[str, Any]    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Tuple):
      a						:		Optional[int]											=      NezhaModel(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Optional[int]											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_)
      a						:		Union[str, Any]											=      model(lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_)
      a						:		str											=      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    :   Optional[Any]    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   List[str]    ,			__UpperCAmelCase    :   Optional[Any]    ,			):
      a						:		Tuple											=      True
      a						:		Dict											=      NezhaModel(lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Dict											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			encoder_hidden_states=lowerCAmelCase_    ,			encoder_attention_mask=lowerCAmelCase_    ,			)
      a						:		Dict											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			encoder_hidden_states=lowerCAmelCase_    ,			)
      a						:		Tuple											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=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    :   Any    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   Optional[Any]):
      a						:		Any											=      NezhaForMaskedLM(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		List[str]											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_)
      self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.seq_length, self.vocab_size))






    def      __snake_case							( self    :   Optional[int]    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   List[Any]    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Union[str, Any]):
      a						:		List[Any]											=      NezhaForNextSentencePrediction(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Optional[int]											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_    ,			)
      self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, 2))






    def      __snake_case							( self    :   Dict    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Union[str, Any]):
      a						:		int											=      NezhaForPreTraining(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		int											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_    ,			next_sentence_label=lowerCAmelCase_    ,			)
      self.parent.assertEqual(result.prediction_logits.shape    ,			(self.batch_size, self.seq_length, self.vocab_size))
      self.parent.assertEqual(result.seq_relationship_logits.shape    ,			(self.batch_size, 2))






    def      __snake_case							( self    :   Tuple    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   Dict    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   List[str]    ,			__UpperCAmelCase    :   Optional[Any]):
      a						:		Tuple											=      NezhaForQuestionAnswering(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Optional[int]											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			start_positions=lowerCAmelCase_    ,			end_positions=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    :   Tuple    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   List[Any]):
      a						:		Dict											=      self.num_labels
      a						:		Any											=      NezhaForSequenceClassification(lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		str											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_)
      self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.num_labels))






    def      __snake_case							( self    :   Union[str, Any]    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Optional[Any]):
      a						:		int											=      self.num_labels
      a						:		str											=      NezhaForTokenClassification(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Union[str, Any]											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_)
      self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.seq_length, self.num_labels))






    def      __snake_case							( self    :   List[str]    ,			__UpperCAmelCase    :   Any    ,			__UpperCAmelCase    :   List[str]    ,			__UpperCAmelCase    :   Tuple    ,			__UpperCAmelCase    :   Optional[int]    ,			__UpperCAmelCase    :   List[Any]    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   int):
      a						:		List[Any]											=      self.num_choices
      a						:		Dict											=      NezhaForMultipleChoice(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      a						:		Optional[int]											=      input_ids.unsqueeze(1).expand(-1    ,			self.num_choices    ,			-1).contiguous()
      a						:		Dict											=      token_type_ids.unsqueeze(1).expand(-1    ,			self.num_choices    ,			-1).contiguous()
      a						:		str											=      input_mask.unsqueeze(1).expand(-1    ,			self.num_choices    ,			-1).contiguous()
      a						:		Any											=      model(
          lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_    ,			token_type_ids=lowerCAmelCase_    ,			labels=lowerCAmelCase_    ,			)
      self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.num_choices))






    def      __snake_case							( self    :   Optional[int]):
      a						:		List[Any]											=      self.prepare_config_and_inputs()
      (
          (
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		  
      )						:		Optional[int]											=      config_and_inputs
      a						:		Union[str, Any]											=      {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
      return config, inputs_dict






@require_torch
class 						_A  (  __lowerCAmelCase   ,__lowerCAmelCase   ,__lowerCAmelCase   ,unittest.TestCase  ):







    """simple docstring"""




    UpperCAmelCase	:							Dict     =	(
        (
            NezhaModel,
            NezhaForMaskedLM,
            NezhaForMultipleChoice,
            NezhaForNextSentencePrediction,
            NezhaForPreTraining,
            NezhaForQuestionAnswering,
            NezhaForSequenceClassification,
            NezhaForTokenClassification,
        )
        if is_torch_available()
        else ()
    )
    UpperCAmelCase	:							Any     =	(
        {
            '''feature-extraction''': NezhaModel,
            '''fill-mask''': NezhaForMaskedLM,
            '''question-answering''': NezhaForQuestionAnswering,
            '''text-classification''': NezhaForSequenceClassification,
            '''token-classification''': NezhaForTokenClassification,
            '''zero-shot''': NezhaForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )
    UpperCAmelCase	:							str     =	True






    def      __snake_case							( self    :   str    ,			__UpperCAmelCase    :   List[str]    ,			__UpperCAmelCase    :   str    ,			__UpperCAmelCase    :   List[Any]=False):
      a						:		Union[str, Any]											=      super()._prepare_for_class(lowerCAmelCase_    ,			lowerCAmelCase_    ,			return_labels=lowerCAmelCase_)

      if return_labels:
        if model_class in get_values(lowerCAmelCase_):
          a						:		str											=      torch.zeros(
              (self.model_tester.batch_size, self.model_tester.seq_length)    ,			dtype=torch.long    ,			device=lowerCAmelCase_)
          a						:		List[str]											=      torch.zeros(
              self.model_tester.batch_size    ,			dtype=torch.long    ,			device=lowerCAmelCase_)
      return inputs_dict






    def      __snake_case							( self    :   Any):
      a						:		Dict											=      NezhaModelTester(self)
      a						:		Any											=      ConfigTester(self    ,			config_class=lowerCAmelCase_    ,			hidden_size=37)






    def      __snake_case							( self    :   str):
      self.config_tester.run_common_tests()






    def      __snake_case							( self    :   Any):
      a						:		Optional[Any]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*lowerCAmelCase_)






    def      __snake_case							( self    :   List[Any]):
      a						:		Union[str, Any]											=      self.model_tester.prepare_config_and_inputs_for_decoder()
      self.model_tester.create_and_check_model_as_decoder(*lowerCAmelCase_)






    def      __snake_case							( self    :   Optional[Any]):
      # This regression test was failing with PyTorch < 1.3
      (
          (
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		(
          a  
      )							,		  
      )						:		str											=      self.model_tester.prepare_config_and_inputs_for_decoder()

      a						:		Any											=      None

      self.model_tester.create_and_check_model_as_decoder(
          lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			lowerCAmelCase_    ,			)






    def      __snake_case							( self    :   List[Any]):
      a						:		Union[str, Any]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase_)






    def      __snake_case							( self    :   Dict):
      a						:		List[str]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*lowerCAmelCase_)






    def      __snake_case							( self    :   List[str]):
      a						:		Tuple											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_next_sequence_prediction(*lowerCAmelCase_)






    def      __snake_case							( self    :   List[Any]):
      a						:		Any											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_pretraining(*lowerCAmelCase_)






    def      __snake_case							( self    :   Optional[Any]):
      a						:		Optional[int]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase_)






    def      __snake_case							( self    :   Optional[int]):
      a						:		Optional[int]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase_)






    def      __snake_case							( self    :   Optional[Any]):
      a						:		Union[str, Any]											=      self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase_)






    @slow
    def      __snake_case							( self    :   Dict):
      for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        a						:		List[str]											=      NezhaModel.from_pretrained(lowerCAmelCase_)
        self.assertIsNotNone(lowerCAmelCase_)






    @slow
    @require_torch_gpu
    def      __snake_case							( self    :   List[str]):
      a							,		a						:		Optional[Any]											=      self.model_tester.prepare_config_and_inputs_for_common()
      for model_class in self.all_model_classes:
        # NezhaForMultipleChoice behaves incorrectly in JIT environments.
        if model_class == NezhaForMultipleChoice:
          return

        a						:		Tuple											=      True
        a						:		Optional[int]											=      model_class(config=lowerCAmelCase_)

        a						:		List[str]											=      self._prepare_for_class(lowerCAmelCase_    ,			lowerCAmelCase_)
        a						:		int											=      torch.jit.trace(
            lowerCAmelCase_    ,			(inputs_dict["input_ids"].to("cpu"), inputs_dict["attention_mask"].to("cpu")))

        with tempfile.TemporaryDirectory() as tmp:
          torch.jit.save(lowerCAmelCase_    ,			os.path.join(lowerCAmelCase_    ,			"bert.pt"))
          a						:		int											=      torch.jit.load(os.path.join(lowerCAmelCase_    ,			"bert.pt")    ,			map_location=lowerCAmelCase_)
          loaded(inputs_dict["input_ids"].to(lowerCAmelCase_)    ,			inputs_dict["attention_mask"].to(lowerCAmelCase_))






@require_torch
class 						_A  (  unittest.TestCase  ):







    """simple docstring"""




    @slow
    def      __snake_case							( self    :   Tuple):
      a						:		str											=      NezhaModel.from_pretrained("sijunhe/nezha-cn-base")
      a						:		int											=      torch.tensor([[0, 1, 2, 3, 4, 5]])
      a						:		Any											=      torch.tensor([[0, 1, 1, 1, 1, 1]])
      with torch.no_grad():
        a						:		List[Any]											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_)[0]
      a						:		List[str]											=      torch.Size((1, 6, 768))
      self.assertEqual(output.shape    ,			lowerCAmelCase_)
      a						:		Optional[int]											=      torch.tensor([[[0.0_685, 0.2_441, 0.1_102], [0.0_600, 0.1_906, 0.1_349], [0.0_221, 0.0_819, 0.0_586]]])

      self.assertTrue(torch.allclose(output[:, 1:4, 1:4]    ,			lowerCAmelCase_    ,			atol=1e-4))






    @slow
    def      __snake_case							( self    :   Optional[Any]):
      a						:		List[Any]											=      NezhaForMaskedLM.from_pretrained("sijunhe/nezha-cn-base")
      a						:		str											=      torch.tensor([[0, 1, 2, 3, 4, 5]])
      a						:		Any											=      torch.tensor([[1, 1, 1, 1, 1, 1]])
      with torch.no_grad():
        a						:		int											=      model(lowerCAmelCase_    ,			attention_mask=lowerCAmelCase_)[0]
      a						:		List[Any]											=      torch.Size((1, 6, 21128))
      self.assertEqual(output.shape    ,			lowerCAmelCase_)
      a						:		Union[str, Any]											=      torch.tensor(
          [[-2.7_939, -1.7_902, -2.2_189], [-2.8_585, -1.8_908, -2.3_723], [-2.6_499, -1.7_750, -2.2_558]])

      self.assertTrue(torch.allclose(output[:, 1:4, 1:4]    ,			lowerCAmelCase_    ,			atol=1e-4))










"""simple docstring"""







from math import ceil, sqrt


def 					lowercase      (    A_ = 1_000_000	)->				int:
  '''simple docstring'''







  a						:		Tuple											=      0

  for outer_width in range(3  ,       (limit // 4) + 2	):
    if outer_width**2 > limit:
      a						:		str											=      max(ceil(sqrt(outer_width**2 - limit	)	)  ,       1	)
    else:
      a						:		Tuple											=      1
    if (outer_width - hole_width_lower_bound) % 2:
      hole_width_lower_bound += 1

    answer += (outer_width - hole_width_lower_bound - 2) // 2 + 1

  return answer


if __name__ == "__main__":
 print(f'''{solution() = }''')






