






import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Value
from .base import TaskTemplate







@dataclass(frozen=_A						)
class  _lowercase   (   _A						):
      # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
      _a							:						str										=							field(default='text-classification'						,				metadata={'include_in_asdict_even_if_is_default': True}						)
      _a							:						ClassVar[Features]										=							Features({'text': Value('string'						)}						)
      _a							:						ClassVar[Features]										=							Features({'labels': ClassLabel}						)
      _a							:						str										=							"text"
      _a							:						str										=							"labels"
      def 						lowercase__					(     self				,			a   ):
       if self.label_column not in features:
        raise ValueError(F"Column {self.label_column} is not present in features."   )
       if not isinstance(features[self.label_column]				,			a   ):
        raise ValueError(F"Column {self.label_column} is not a ClassLabel."   )
       snake_case__  :    List[str]							       =copy.deepcopy(self   )
       snake_case__  :    Any							       =self.label_schema.copy()
       snake_case__  :    Dict							       =features[self.label_column]
       snake_case__  :    str							       =label_schema
       return task_template



      @property
      def 						lowercase__					(     self   ):
       return {
           self.text_column: "text",
           self.label_column: "labels",
       }













import argparse

from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird
from transformers.utils import logging


logging.set_verbosity_info()







def 			A__							(      _a  :					int		,  _a  :					Any		,  _a  :					Union[str, Any]		,  _a  :					Tuple	):





 '''simple docstring'''







 snake_case__  :    Any							       =BigBirdConfig.from_json_file(_a	)
 print(f"Building PyTorch model from configuration: {config}"	)

 if is_trivia_qa:
  snake_case__  :    str							       =BigBirdForQuestionAnswering(_a	)
 else:
  snake_case__  :    Optional[int]							       =BigBirdForPreTraining(_a	)

 # Load weights from tf checkpoint
 load_tf_weights_in_big_bird(_a		,  _a		,  is_trivia_qa=_a	)

 # Save pytorch-model
 print(f"Save PyTorch model to {pytorch_dump_path}"	)
 model.save_pretrained(_a	)


if __name__ == "__main__":
       __lowerCamelCase	:		Union[str, Any]										=   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(
           """--big_bird_config_file""",
           default=None,
           type=str,
           required=True,
           help=(
               """The config json file corresponding to the pre-trained BERT 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."""
       )
       parser.add_argument(
           """--is_trivia_qa""", action="""store_true""", help="""Whether to convert a model with a trivia_qa head."""
       )
       __lowerCamelCase	:		Tuple										=   parser.parse_args()
       convert_tf_checkpoint_to_pytorch(
           args.tf_checkpoint_path, args.big_bird_config_file, args.pytorch_dump_path, args.is_trivia_qa
       )





