code: 
  
  """simple docstring"""
  import unittest
  
  from cer import CER
  
  
  _A						=     CER()
  
  class 			lowerCamelCase  (					unittest.TestCase      ):
  
  
    '''simple docstring'''
  
  
  
  
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Optional[int]						=						["White House"]
          UpperCAmelCase__ :       Dict						=						["white house"]
          # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
          UpperCAmelCase__ :       List[str]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.1_818_181_818  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       int						=						["were wolf"]
          UpperCAmelCase__ :       Union[str, Any]						=						["werewolf"]
          # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
          UpperCAmelCase__ :       str						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.1_111_111  ) < 1e-6  )
  
          UpperCAmelCase__ :       Dict						=						["werewolf"]
          UpperCAmelCase__ :       List[str]						=						["weae     wolf"]
          # S = 1, D = 1, I = 0, N = 8, CER = 0.25
          UpperCAmelCase__ :       List[str]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.25  ) < 1e-6  )
  
          # consecutive whitespaces case 1
          UpperCAmelCase__ :       Optional[Any]						=						["were wolf"]
          UpperCAmelCase__ :       Tuple						=						["were               wolf"]
          # S = 0, D = 0, I = 0, N = 9, CER = 0
          UpperCAmelCase__ :       Optional[Any]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.0  ) < 1e-6  )
  
          # consecutive whitespaces case 2
          UpperCAmelCase__ :       List[Any]						=						["were   wolf"]
          UpperCAmelCase__ :       int						=						["were               wolf"]
          # S = 0, D = 0, I = 0, N = 9, CER = 0
          UpperCAmelCase__ :       Optional[Any]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.0  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       str						=						["werewolf"]
          UpperCAmelCase__ :       List[Any]						=						["weaewolf"]
          # S = 1, D = 0, I = 0, N = 8, CER = 0.125
          UpperCAmelCase__ :       Tuple						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.125  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Optional[int]						=						["werewolf"]
          UpperCAmelCase__ :       List[str]						=						["wereawolf"]
          # S = 0, D = 1, I = 0, N = 8, CER = 0.125
          UpperCAmelCase__ :       List[str]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.125  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       List[Any]						=						["werewolf"]
          UpperCAmelCase__ :       Any						=						["wereolf"]
          # S = 0, D = 0, I = 1, N = 8, CER = 0.125
          UpperCAmelCase__ :       List[str]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.125  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Optional[Any]						=						["werewolf"]
          UpperCAmelCase__ :       str						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertEqual(lowerCamelCase__       ,					0.0  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Dict						=						["werewolf", "I am your father"]
          UpperCAmelCase__ :       Optional[Any]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertEqual(lowerCamelCase__       ,					0.0  )
  
          UpperCAmelCase__ :       str						=						["werewolf", "I am your father", "doge"]
          UpperCAmelCase__ :       Tuple						=						["werxwolf", "I       am your father", "doge"]
          # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
          UpperCAmelCase__ :       str						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.03_571_428  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       List[str]						=						["My hovercraft", "is full of eels"]
          UpperCAmelCase__ :       Tuple						=						["My hovercraft is full", " of eels"]
          # S = 0, D = 0, I = 2, N = 28, CER = 2 / 28
          # whitespace at the front of " of eels" will be strip during preporcessing
          # so need to insert 2 whitespaces
          UpperCAmelCase__ :       int						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__       ,					concatenate_texts=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.071_428  ) < 1e-6  )
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Any						=						["我能吞下玻璃而不伤身体"]
          UpperCAmelCase__ :       List[str]						=						[" 能吞虾玻璃而 不霜身体啦"]
          # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
          UpperCAmelCase__ :       Optional[int]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.4_545_454_545  ) < 1e-6  )
  
          UpperCAmelCase__ :       Optional[int]						=						["我能吞下玻璃", "而不伤身体"]
          UpperCAmelCase__ :       Dict						=						["我    能 吞 下 玻 璃", "而不伤身体"]
          # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
          UpperCAmelCase__ :       Tuple						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertTrue(abs(char_error_rate - 0.454_545_454_545  ) < 1e-6  )
  
          UpperCAmelCase__ :       Any						=						["我能吞下玻璃而不伤身体"]
          UpperCAmelCase__ :       Optional[int]						=						cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
          self.assertFalse(lowerCamelCase__       ,					0.0  )
  
  
  
  
    def    _a			(self  ):
  
  
          """simple docstring"""
  
          UpperCAmelCase__ :       Optional[Any]						=						[""]
          UpperCAmelCase__ :       str						=						["Hypothesis"]
          with self.assertRaises(lowerCamelCase__  ):
                cer.compute(predictions=lowerCamelCase__       ,					references=lowerCamelCase__  )
  
  
  if __name__ == "__main__":
      unittest.main()
  
  
  
  
  
  
style_context: 
  
  """simple docstring"""
  import argparse
  import json
  
  from transformers import GPTNeoConfig, GPTNeoForCausalLM, load_tf_weights_in_gpt_neo
  from transformers.utils import logging
  
  
  logging.set_verbosity_info()
  
  
  
  
  def 				a__	(	lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)  ->   Dict:
        # Initialise PyTorch model
        UpperCAmelCase__ :       Union[str, Any]						=						json.load(open(lowerCAmelCase ,  """r"""						)						)
        UpperCAmelCase__ :       Any						=						GPTNeoConfig(
            hidden_size=config_json["""n_embd"""] ,  num_layers=config_json["""n_layer"""] ,  num_heads=config_json["""n_head"""] ,  attention_types=config_json["""attention_types"""] ,  max_position_embeddings=config_json["""n_positions"""] ,  resid_dropout=config_json["""res_dropout"""] ,  embed_dropout=config_json["""embed_dropout"""] ,  attention_dropout=config_json["""attn_dropout"""] ,  )
        print(F"""Building PyTorch model from configuration: {config}"""						)
        UpperCAmelCase__ :       Dict						=						GPTNeoForCausalLM(lowerCAmelCase						)
  
        # Load weights from tf checkpoint
        load_tf_weights_in_gpt_neo(lowerCAmelCase ,  lowerCAmelCase ,  lowerCAmelCase						)
  
        # Save pytorch-model
        print(F"""Save PyTorch model to {pytorch_dump_path}"""						)
        model.save_pretrained(lowerCAmelCase						)
  
  
  if __name__ == "__main__":
      _A						=     argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """--tf_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
      )
      parser.add_argument(
          """--config_file""",
          default=None,
          type=str,
          required=True,
          help=(
              """The config json file corresponding to the pre-trained mesh-tf model. \n"""
              """This specifies the model architecture."""
          ),
      )
      parser.add_argument(
          """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
      )
      _A						=     parser.parse_args()
      convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)
  
  