code: 
  
  
  
  
  import argparse
  
  import torch
  
  from transformers import ElectraConfig, ElectraForMaskedLM, ElectraForPreTraining, load_tf_weights_in_electra
  from transformers.utils import logging
  
  
  logging.set_verbosity_info()
  
  
  def 						_A     (       SCREAMING_SNAKE_CASE__						:			Optional[Any]  ,						SCREAMING_SNAKE_CASE__						:			Optional[int]  ,						SCREAMING_SNAKE_CASE__						:			Any  ,						SCREAMING_SNAKE_CASE__						:			Any ):
      # Initialise PyTorch model
      UpperCamelCase :Optional[int]										=     ElectraConfig.from_json_file(lowercase__ )
      print(F'''Building PyTorch model from configuration: {config}''' )
  
      if discriminator_or_generator == "discriminator":
          UpperCamelCase :str										=     ElectraForPreTraining(lowercase__ )
      elif discriminator_or_generator == "generator":
          UpperCamelCase :Optional[int]										=     ElectraForMaskedLM(lowercase__ )
      else:
          raise ValueError('''The discriminator_or_generator argument should be either \'discriminator\' or \'generator\'''' )
  
      # Load weights from tf checkpoint
      load_tf_weights_in_electra(
          lowercase__  ,						lowercase__  ,						lowercase__  ,						discriminator_or_generator=lowercase__ )
  
      # Save pytorch-model
      print(F'''Save PyTorch model to {pytorch_dump_path}''' )
      torch.save(model.state_dict()  ,						lowercase__ )
  
  
  if __name__ == "__main__":
   __snake_case							      =						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 model. \nThis specifies the model architecture.""",
   )
   parser.add_argument(
       """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
   )
   parser.add_argument(
       """--discriminator_or_generator""",
       default=None,
       type=str,
       required=True,
       help=(
           """Whether to export the generator or the discriminator. Should be a string, either \'discriminator\' or """
           """\'generator\'."""
       ),
   )
   __snake_case							      =						parser.parse_args()
   convert_tf_checkpoint_to_pytorch(
       args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.discriminator_or_generator
   )
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  
  from __future__ import annotations
  
  from typing import Generic, TypeVar
  
  __snake_case							      =						TypeVar("""T""")
  
  
  
  
  
  
  
  class     UpperCAmelCase_		(      lowercase				):
  
  
  
        """simple docstring"""
        pass
  
  
  
  
  
  
  
  class     UpperCAmelCase_		(      lowercase				):
  
  
  
        """simple docstring"""
        pass
  
  
  
  
  
  
  
  class     UpperCAmelCase_		(      Generic[T]				):
  
  
  
        """simple docstring"""
        def __init__(       self					,       SCREAMING_SNAKE_CASE_ = 10				)       ->   List[str]:
            UpperCamelCase :list[T]										=     []
            UpperCamelCase :Any										=     limit
        def __bool__(       self				)       ->   bool:
            return bool(self.stack				)
        def __str__(       self				)       ->   str:
            return str(self.stack				)
        def 					UpperCAmelCase		(       self					,       SCREAMING_SNAKE_CASE_				)       ->   None:
            if len(self.stack				) >= self.limit:
                raise StackOverflowError
            self.stack.append(SCREAMING_SNAKE_CASE_				)
        def 					UpperCAmelCase		(       self				)       ->   T:
            if not self.stack:
                raise StackUnderflowError
            return self.stack.pop()
        def 					UpperCAmelCase		(       self				)       ->   T:
            if not self.stack:
                raise StackUnderflowError
            return self.stack[-1]
        def 					UpperCAmelCase		(       self				)       ->   bool:
            return not bool(self.stack				)
        def 					UpperCAmelCase		(       self				)       ->   bool:
            return self.size() == self.limit
        def 					UpperCAmelCase		(       self				)       ->   int:
            return len(self.stack				)
  
  
  
  
        def __contains__(       self					,       SCREAMING_SNAKE_CASE_				)       ->   bool:
            return item in self.stack
  
  
  
  
  
  
  
  def 						_A     (       ):
      UpperCamelCase :Stack[int]										=     Stack(10 )
      assert bool(SCREAMING_SNAKE_CASE__ ) is False
      assert stack.is_empty() is True
      assert stack.is_full() is False
      assert str(SCREAMING_SNAKE_CASE__ ) == "[]"
  
      try:
          UpperCamelCase :Optional[int]										=     stack.pop()
          raise AssertionError  # This should not happen
      except StackUnderflowError:
          assert True  # This should happen
  
      try:
          UpperCamelCase :Union[str, Any]										=     stack.peek()
          raise AssertionError  # This should not happen
      except StackUnderflowError:
          assert True  # This should happen
  
      for i in range(10 ):
          assert stack.size() == i
          stack.push(SCREAMING_SNAKE_CASE__ )
  
      assert bool(SCREAMING_SNAKE_CASE__ )
      assert not stack.is_empty()
      assert stack.is_full()
      assert str(SCREAMING_SNAKE_CASE__ ) == str(list(range(10 ) ) )
      assert stack.pop() == 9
      assert stack.peek() == 8
  
      stack.push(100 )
      assert str(SCREAMING_SNAKE_CASE__ ) == str([0, 1, 2, 3, 4, 5, 6, 7, 8, 100] )
  
      try:
          stack.push(200 )
          raise AssertionError  # This should not happen
      except StackOverflowError:
          assert True  # This should happen
  
      assert not stack.is_empty()
      assert stack.size() == 10
  
      assert 5 in stack
      assert 55 not in stack
  
  
  if __name__ == "__main__":
   test_stack()
  
  
  
  
  
  