




from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_lowerCamelCase      			=						logging.get_logger(__name__)

_lowerCamelCase      			=						{
    'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json',
    # See all Nat models at https://huggingface.co/models?filter=nat
}



class       a					(       _A     ,       _A      ):

					'''simple docstring'''





					lowerCAmelCase    :	Tuple       		=  'nat'

					lowerCAmelCase    :	str       		=  {
					    'num_attention_heads': 'num_heads',
					    'num_hidden_layers': 'num_layers',
					}
					def __init__(     self       :      Any ,   __snake_case       :      Dict=4 ,   __snake_case       :      str=3 ,   __snake_case       :      Optional[Any]=64 ,   __snake_case       :      str=[3, 4, 6, 5] ,   __snake_case       :      List[str]=[2, 4, 8, 16] ,   __snake_case       :      Dict=7 ,   __snake_case       :      Tuple=3.0 ,   __snake_case       :      str=True ,   __snake_case       :      Tuple=0.0 ,   __snake_case       :      Tuple=0.0 ,   __snake_case       :      Union[str, Any]=0.1 ,   __snake_case       :      Optional[Any]="gelu" ,   __snake_case       :      Optional[int]=0.02 ,   __snake_case       :      int=1E-5 ,   __snake_case       :      Optional[int]=0.0 ,   __snake_case       :      List[Any]=None ,   __snake_case       :      List[str]=None ,   **__snake_case       :      Optional[Any] ,   ):
									super().__init__(**_SCREAMING_SNAKE_CASE    )

									UpperCAmelCase_										=					patch_size
									UpperCAmelCase_										=					num_channels
									UpperCAmelCase_										=					embed_dim
									UpperCAmelCase_										=					depths
									UpperCAmelCase_										=					len(_SCREAMING_SNAKE_CASE    )
									UpperCAmelCase_										=					num_heads
									UpperCAmelCase_										=					kernel_size
									UpperCAmelCase_										=					mlp_ratio
									UpperCAmelCase_										=					qkv_bias
									UpperCAmelCase_										=					hidden_dropout_prob
									UpperCAmelCase_										=					attention_probs_dropout_prob
									UpperCAmelCase_										=					drop_path_rate
									UpperCAmelCase_										=					hidden_act
									UpperCAmelCase_										=					layer_norm_eps
									UpperCAmelCase_										=					initializer_range
									# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
									# this indicates the channel dimension after the last stage of the model
									UpperCAmelCase_										=					int(embed_dim * 2 ** (len(_SCREAMING_SNAKE_CASE    ) - 1)    )
									UpperCAmelCase_										=					layer_scale_init_value
									UpperCAmelCase_										=					['''stem'''] + [F'stage{idx}' for idx in range(1 ,   len(_SCREAMING_SNAKE_CASE    ) + 1    )]
									UpperCAmelCase_										=					get_aligned_output_features_output_indices(
									    out_features=_SCREAMING_SNAKE_CASE ,   out_indices=_SCREAMING_SNAKE_CASE ,   stage_names=self.stage_names    )











import argparse
import logging
import pickle
from collections import Counter


logging.basicConfig(
    format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO
)
_lowerCamelCase      			=						logging.getLogger(__name__)

if __name__ == "__main__":
 _lowerCamelCase      			=						argparse.ArgumentParser(
     description='Token Counts for smoothing the masking probabilities in MLM (cf XLM/word2vec)'
 )
 parser.add_argument(
     '--data_file', type=str, default='data/dump.bert-base-uncased.pickle', help='The binarized dataset.'
 )
 parser.add_argument(
     '--token_counts_dump', type=str, default='data/token_counts.bert-base-uncased.pickle', help='The dump file.'
 )
 parser.add_argument('--vocab_size', default=3_05_22, type=int)
 _lowerCamelCase      			=						parser.parse_args()

 logger.info(F"Loading data from {args.data_file}")
 with open(args.data_file, 'rb') as fp:
  _lowerCamelCase      			=						pickle.load(fp)

 logger.info('Counting occurrences for MLM.')
 _lowerCamelCase      			=						Counter()
 for tk_ids in data:
  counter.update(tk_ids)
 _lowerCamelCase      			=						[0] * args.vocab_size
 for k, v in counter.items():
  _lowerCamelCase      			=						v

 logger.info(F"Dump to {args.token_counts_dump}")
 with open(args.token_counts_dump, 'wb') as handle:
  pickle.dump(counts, handle, protocol=pickle.HIGHEST_PROTOCOL)





