


'''simple docstring'''





from __future__ import annotations

import unittest

from transformers import RoFormerConfig, is_tf_available
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 (
           TFRoFormerForCausalLM,
           TFRoFormerForMaskedLM,
           TFRoFormerForMultipleChoice,
           TFRoFormerForQuestionAnswering,
           TFRoFormerForSequenceClassification,
           TFRoFormerForTokenClassification,
           TFRoFormerModel,
       )
       from transformers.models.roformer.modeling_tf_roformer import (
           TFRoFormerSelfAttention,
           TFRoFormerSinusoidalPositionalEmbedding,
       )

class       __magic_name__	:


     def __init__(      self							:     int							,	lowerCamelCase__							:     List[Any]							,	lowerCamelCase__							:     Union[str, Any]=13							,	lowerCamelCase__							:     str=7							,	lowerCamelCase__							:     str=True							,	lowerCamelCase__							:     int=True							,	lowerCamelCase__							:     Union[str, Any]=True							,	lowerCamelCase__							:     List[Any]=True							,	lowerCamelCase__							:     Any=99							,	lowerCamelCase__							:     Dict=32							,	lowerCamelCase__							:     List[Any]=2							,	lowerCamelCase__							:     int=4							,	lowerCamelCase__							:     Tuple=37							,	lowerCamelCase__							:     str="gelu"							,	lowerCamelCase__							:     List[Any]=0.1							,	lowerCamelCase__							:     str=0.1							,	lowerCamelCase__							:     List[Any]=512							,	lowerCamelCase__							:     Optional[Any]=16							,	lowerCamelCase__							:     Any=2							,	lowerCamelCase__							:     Optional[Any]=0.02							,	lowerCamelCase__							:     Optional[int]=3							,	lowerCamelCase__							:     Dict=4							,	lowerCamelCase__							:     List[str]=None							,	)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    Union[str, Any]          =   parent
      UpperCamelCase__					:    Dict          =   13
      UpperCamelCase__					:    List[str]          =   7
      UpperCamelCase__					:    Tuple          =   True
      UpperCamelCase__					:    Dict          =   True
      UpperCamelCase__					:    str          =   True
      UpperCamelCase__					:    Tuple          =   True
      UpperCamelCase__					:    Optional[Any]          =   99
      UpperCamelCase__					:    List[str]          =   32
      UpperCamelCase__					:    Any          =   2
      UpperCamelCase__					:    Optional[int]          =   4
      UpperCamelCase__					:    Tuple          =   37
      UpperCamelCase__					:    Dict          =   '''gelu'''
      UpperCamelCase__					:    str          =   0.1
      UpperCamelCase__					:    List[str]          =   0.1
      UpperCamelCase__					:    int          =   512
      UpperCamelCase__					:    Tuple          =   16
      UpperCamelCase__					:    Dict          =   2
      UpperCamelCase__					:    Dict          =   0.02
      UpperCamelCase__					:    Optional[int]          =   3
      UpperCamelCase__					:    Tuple          =   4
      UpperCamelCase__					:    Any          =   None


     def      UpperCAmelCase__	(      self							:     str			)  ->      Union[str, Any]:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   ids_tensor([self.batch_size, self.seq_length]							,	self.vocab_size			)

      UpperCamelCase__					:    Tuple          =   None
      if self.use_input_mask:
       UpperCamelCase__					:    Optional[Any]          =   random_attention_mask([self.batch_size, self.seq_length]			)

      UpperCamelCase__					:    Union[str, Any]          =   None
      if self.use_token_type_ids:
       UpperCamelCase__					:    int          =   ids_tensor([self.batch_size, self.seq_length]							,	self.type_vocab_size			)

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

      UpperCamelCase__					:    Dict          =   RoFormerConfig(
          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							,	initializer_range=self.initializer_range							,	return_dict=lowerCamelCase__							,	)

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


     def      UpperCAmelCase__	(      self							:     List[Any]							,	lowerCamelCase__							:     List[str]							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     List[Any]							,	lowerCamelCase__							:     Optional[int]							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Dict							,	lowerCamelCase__							:     Any			)  ->      Any:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   TFRoFormerModel(config=lowerCamelCase__			)
      UpperCamelCase__					:    int          =   {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

      UpperCamelCase__					:    List[str]          =   [input_ids, input_mask]
      UpperCamelCase__					:    Optional[int]          =   model(lowerCamelCase__			)

      UpperCamelCase__					:    List[Any]          =   model(lowerCamelCase__			)

      self.parent.assertEqual(result.last_hidden_state.shape							,	(self.batch_size, self.seq_length, self.hidden_size)			)


     def      UpperCAmelCase__	(      self							:     Tuple							,	lowerCamelCase__							:     Dict							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     Tuple							,	lowerCamelCase__							:     Tuple							,	lowerCamelCase__							:     List[Any]							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     int			)  ->      Union[str, Any]:





      '''simple docstring'''






      UpperCamelCase__					:    Optional[int]          =   True
      UpperCamelCase__					:    Tuple          =   TFRoFormerForCausalLM(config=lowerCamelCase__			)
      UpperCamelCase__					:    Union[str, Any]          =   {
          '''input_ids''': input_ids,
          '''attention_mask''': input_mask,
          '''token_type_ids''': token_type_ids,
      }
      UpperCamelCase__					:    Dict          =   model(lowerCamelCase__			)['''logits''']
      self.parent.assertListEqual(
          list(prediction_scores.numpy().shape			)							,	[self.batch_size, self.seq_length, self.vocab_size]			)


     def      UpperCAmelCase__	(      self							:     Tuple							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     List[str]							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Dict							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     int			)  ->      Union[str, Any]:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   TFRoFormerForMaskedLM(config=lowerCamelCase__			)
      UpperCamelCase__					:    str          =   {
          '''input_ids''': input_ids,
          '''attention_mask''': input_mask,
          '''token_type_ids''': token_type_ids,
      }
      UpperCamelCase__					:    str          =   model(lowerCamelCase__			)
      self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.seq_length, self.vocab_size)			)


     def      UpperCAmelCase__	(      self							:     Optional[Any]							,	lowerCamelCase__							:     Tuple							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     Any			)  ->      List[Any]:





      '''simple docstring'''






      UpperCamelCase__					:    int          =   self.num_labels
      UpperCamelCase__					:    int          =   TFRoFormerForSequenceClassification(config=lowerCamelCase__			)
      UpperCamelCase__					:    Optional[int]          =   {
          '''input_ids''': input_ids,
          '''attention_mask''': input_mask,
          '''token_type_ids''': token_type_ids,
      }

      UpperCamelCase__					:    Dict          =   model(lowerCamelCase__			)
      self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.num_labels)			)


     def      UpperCAmelCase__	(      self							:     str							,	lowerCamelCase__							:     List[Any]							,	lowerCamelCase__							:     Tuple							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     Optional[int]							,	lowerCamelCase__							:     Optional[int]							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     Dict			)  ->      Tuple:





      '''simple docstring'''






      UpperCamelCase__					:    Optional[Any]          =   self.num_choices
      UpperCamelCase__					:    List[Any]          =   TFRoFormerForMultipleChoice(config=lowerCamelCase__			)
      UpperCamelCase__					:    Optional[int]          =   tf.tile(tf.expand_dims(lowerCamelCase__							,	1			)							,	(1, self.num_choices, 1)			)
      UpperCamelCase__					:    int          =   tf.tile(tf.expand_dims(lowerCamelCase__							,	1			)							,	(1, self.num_choices, 1)			)
      UpperCamelCase__					:    List[Any]          =   tf.tile(tf.expand_dims(lowerCamelCase__							,	1			)							,	(1, self.num_choices, 1)			)
      UpperCamelCase__					:    Any          =   {
          '''input_ids''': multiple_choice_inputs_ids,
          '''attention_mask''': multiple_choice_input_mask,
          '''token_type_ids''': multiple_choice_token_type_ids,
      }
      UpperCamelCase__					:    int          =   model(lowerCamelCase__			)
      self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.num_choices)			)


     def      UpperCAmelCase__	(      self							:     List[Any]							,	lowerCamelCase__							:     List[str]							,	lowerCamelCase__							:     List[Any]							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Optional[int]							,	lowerCamelCase__							:     List[str]			)  ->      int:





      '''simple docstring'''






      UpperCamelCase__					:    Tuple          =   self.num_labels
      UpperCamelCase__					:    str          =   TFRoFormerForTokenClassification(config=lowerCamelCase__			)
      UpperCamelCase__					:    List[str]          =   {
          '''input_ids''': input_ids,
          '''attention_mask''': input_mask,
          '''token_type_ids''': token_type_ids,
      }
      UpperCamelCase__					:    str          =   model(lowerCamelCase__			)
      self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.seq_length, self.num_labels)			)


     def      UpperCAmelCase__	(      self							:     Dict							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Tuple							,	lowerCamelCase__							:     Optional[Any]							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Any							,	lowerCamelCase__							:     Union[str, Any]							,	lowerCamelCase__							:     Optional[int]			)  ->      str:





      '''simple docstring'''






      UpperCamelCase__					:    str          =   TFRoFormerForQuestionAnswering(config=lowerCamelCase__			)
      UpperCamelCase__					:    int          =   {
          '''input_ids''': input_ids,
          '''attention_mask''': input_mask,
          '''token_type_ids''': token_type_ids,
      }

      UpperCamelCase__					:    Optional[Any]          =   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      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Tuple:





      '''simple docstring'''






      UpperCamelCase__					:    int          =   self.prepare_config_and_inputs()
      (
          (
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,				(
          UpperCamelCase__					
      )       ,									
      )					:    Optional[int]          =   config_and_inputs
      UpperCamelCase__					:    Tuple          =   {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
      return config, inputs_dict



@require_tf
class       __magic_name__	(     lowercase_					,				lowercase_					,				unittest.TestCase):
     A:		Union[str, Any]			=      (
         (
             TFRoFormerModel,
             TFRoFormerForCausalLM,
             TFRoFormerForMaskedLM,
             TFRoFormerForQuestionAnswering,
             TFRoFormerForSequenceClassification,
             TFRoFormerForTokenClassification,
             TFRoFormerForMultipleChoice,
         )
         if is_tf_available()
         else ()
     )
     A:		List[Any]			=      (
         {
             '''feature-extraction''': TFRoFormerModel,
             '''fill-mask''': TFRoFormerForMaskedLM,
             '''question-answering''': TFRoFormerForQuestionAnswering,
             '''text-classification''': TFRoFormerForSequenceClassification,
             '''text-generation''': TFRoFormerForCausalLM,
             '''token-classification''': TFRoFormerForTokenClassification,
             '''zero-shot''': TFRoFormerForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )

     A:		Tuple			=      False
     A:		Union[str, Any]			=      False


     def      UpperCAmelCase__	(      self							:     int							,	lowerCamelCase__							:     Optional[Any]							,	lowerCamelCase__							:     Optional[Any]							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     Tuple			)  ->      Dict:





      '''simple docstring'''






      if pipeline_test_casse_name == "TextGenerationPipelineTests":
       return True

      return False


     def      UpperCAmelCase__	(      self							:     str			)  ->      Tuple:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   TFRoFormerModelTester(self			)
      UpperCamelCase__					:    Dict          =   ConfigTester(self							,	config_class=lowerCamelCase__							,	hidden_size=37			)


     def      UpperCAmelCase__	(      self							:     int			)  ->      Dict:





      '''simple docstring'''






      self.config_tester.run_common_tests()


     def      UpperCAmelCase__	(      self							:     List[str]			)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    Optional[int]          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     Optional[Any]			)  ->      Optional[int]:





      '''simple docstring'''






      UpperCamelCase__					:    int          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     Any			)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    str          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_lm_head(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     Optional[int]			)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     List[Any]			)  ->      Any:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Tuple:





      '''simple docstring'''






      UpperCamelCase__					:    List[str]          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase__			)


     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Union[str, Any]:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*lowerCamelCase__			)


     @slow
     def      UpperCAmelCase__	(      self							:     Optional[int]			)  ->      Any:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   TFRoFormerModel.from_pretrained('''junnyu/roformer_chinese_base'''			)
      self.assertIsNotNone(lowerCamelCase__			)



@require_tf
class       __magic_name__	(     unittest.TestCase):


     @slow
     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    Union[str, Any]          =   TFRoFormerForMaskedLM.from_pretrained('''junnyu/roformer_chinese_base'''			)
      UpperCamelCase__					:    Any          =   tf.constant([[0, 1, 2, 3, 4, 5]]			)
      UpperCamelCase__					:    Any          =   model(lowerCamelCase__			)[0]

      # TODO Replace vocab size
      UpperCamelCase__					:    Union[str, Any]          =   50000

      UpperCamelCase__					:    Dict          =   [1, 6, vocab_size]
      self.assertEqual(output.shape							,	lowerCamelCase__			)

      print(output[:, :3, :3]			)

      # TODO Replace values below with what was printed above.
      UpperCamelCase__					:    Optional[int]          =   tf.constant(
          [
              [
                  [-0.1205_3341, -1.026_4901, 0.2922_1946],
                  [-1.513_3783, 0.19_7433, 0.1519_0607],
                  [-5.013_5403, -3.90_0256, -0.8403_8764],
              ]
          ]			)
      tf.debugging.assert_near(output[:, :3, :3]							,	lowerCamelCase__							,	atol=1E-4			)



@require_tf
class       __magic_name__	(     unittest.TestCase):
     A:		Dict			=      1E-4


     def      UpperCAmelCase__	(      self							:     Tuple			)  ->      Optional[int]:





      '''simple docstring'''






      UpperCamelCase__					:    Any          =   tf.constant([[4, 10]]			)
      UpperCamelCase__					:    Any          =   TFRoFormerSinusoidalPositionalEmbedding(num_positions=6							,	embedding_dim=6			)

      UpperCamelCase__					:    Optional[Any]          =   emba(input_ids.shape			)
      UpperCamelCase__					:    Optional[int]          =   tf.constant(
          [[0.0000, 0.0000, 0.0000, 1.0000, 1.0000, 1.0000], [0.8415, 0.0464, 0.0022, 0.5403, 0.9989, 1.0000]]			)

      tf.debugging.assert_near(lowerCamelCase__							,	lowerCamelCase__							,	atol=self.tolerance			)


     def      UpperCAmelCase__	(      self							:     Tuple			)  ->      int:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   tf.constant(
          [
              [0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
              [0.8415, 0.8219, 0.8020, 0.7819, 0.7617],
              [0.9093, 0.9364, 0.9581, 0.9749, 0.9870],
          ]			)
      UpperCamelCase__					:    int          =   TFRoFormerSinusoidalPositionalEmbedding(num_positions=512							,	embedding_dim=512			)
      emba([2, 16, 512]			)
      UpperCamelCase__					:    str          =   emba.weight[:3, :5]

      tf.debugging.assert_near(lowerCamelCase__							,	lowerCamelCase__							,	atol=self.tolerance			)



@require_tf
class       __magic_name__	(     unittest.TestCase):
     A:		str			=      1E-4


     def      UpperCAmelCase__	(      self							:     Optional[int]			)  ->      Optional[int]:





      '''simple docstring'''






      UpperCamelCase__					:    str          =   tf.reshape(tf.range(2 * 12 * 16 * 64							,	dtype=tf.floataa			)							,	shape=(2, 12, 16, 64)			) / 100

      UpperCamelCase__					:    Tuple          =   -tf.reshape(tf.range(2 * 12 * 16 * 64							,	dtype=tf.floataa			)							,	shape=(2, 12, 16, 64)			) / 100

      UpperCamelCase__					:    str          =   TFRoFormerSinusoidalPositionalEmbedding(num_positions=32							,	embedding_dim=64			)
      UpperCamelCase__					:    Any          =   embed_positions([2, 16, 768]			)[None, None, :, :]

      UpperCamelCase__       ,				UpperCamelCase__					:    Union[str, Any]          =   TFRoFormerSelfAttention.apply_rotary_position_embeddings(
          lowerCamelCase__							,	lowerCamelCase__							,	lowerCamelCase__			)

      UpperCamelCase__					:    str          =   tf.constant(
          [
              [0.0000, 0.0100, 0.0200, 0.0300, 0.0400, 0.0500, 0.0600, 0.0700],
              [-0.2012, 0.8897, 0.0263, 0.9401, 0.2074, 0.9463, 0.3481, 0.9343],
              [-1.7057, 0.6271, -1.2145, 1.3897, -0.6303, 1.7647, -0.1173, 1.8985],
              [-2.1731, -1.6397, -2.7358, 0.2854, -2.1840, 1.7183, -1.3018, 2.4871],
              [0.2717, -3.6173, -2.9206, -2.1988, -3.6638, 0.3858, -2.9155, 2.2980],
              [3.9859, -2.1580, -0.7984, -4.4904, -4.1181, -2.0252, -4.4782, 1.1253],
          ]			)
      UpperCamelCase__					:    str          =   tf.constant(
          [
              [0.0000, -0.0100, -0.0200, -0.0300, -0.0400, -0.0500, -0.0600, -0.0700],
              [0.2012, -0.8897, -0.0263, -0.9401, -0.2074, -0.9463, -0.3481, -0.9343],
              [1.7057, -0.6271, 1.2145, -1.3897, 0.6303, -1.7647, 0.1173, -1.8985],
              [2.1731, 1.6397, 2.7358, -0.2854, 2.1840, -1.7183, 1.3018, -2.4871],
              [-0.2717, 3.6173, 2.9206, 2.1988, 3.6638, -0.3858, 2.9155, -2.2980],
              [-3.9859, 2.1580, 0.7984, 4.4904, 4.1181, 2.0252, 4.4782, -1.1253],
          ]			)

      tf.debugging.assert_near(query_layer[0, 0, :6, :8]							,	lowerCamelCase__							,	atol=self.tolerance			)
      tf.debugging.assert_near(key_layer[0, 0, :6, :8]							,	lowerCamelCase__							,	atol=self.tolerance			)






import functools

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				str     ):







 """simple docstring"""



 UpperCamelCase__					:    str          =   len(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Optional[Any]          =   len(SCREAMING_SNAKE_CASE     )

 @functools.cache
 def min_distance(SCREAMING_SNAKE_CASE	:				int    , SCREAMING_SNAKE_CASE	:				int     ) -> int:
  # if first word index is overflow - delete all from the second word
  if indexa >= len_worda:
   return len_worda - indexa
  # if second word index is overflow - delete all from the first word
  if indexa >= len_worda:
   return len_worda - indexa
  UpperCamelCase__					:    Tuple          =   int(worda[indexa] != worda[indexa]     )  # current letters not identical
  return min(
      1 + min_distance(indexa + 1    , SCREAMING_SNAKE_CASE     )    , 1 + min_distance(SCREAMING_SNAKE_CASE    , indexa + 1     )    , diff + min_distance(indexa + 1    , indexa + 1     )    , )

 return min_distance(0    , 0     )


if __name__ == "__main__":
       import doctest

       doctest.testmod()


