




'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase_       				=      logging.get_logger(__name__)

UpperCAmelCase_       				=      {
    "nghuyong/ernie-1.0-base-zh": "https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json",
    "nghuyong/ernie-2.0-base-en": "https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json",
    "nghuyong/ernie-2.0-large-en": "https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json",
    "nghuyong/ernie-3.0-base-zh": "https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-medium-zh": "https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-mini-zh": "https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-micro-zh": "https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json",
    "nghuyong/ernie-3.0-nano-zh": "https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json",
    "nghuyong/ernie-gram-zh": "https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json",
    "nghuyong/ernie-health-zh": "https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json",
}

class 						lowerCAmelCase_   ( snake_case__   ):







		'''simple docstring'''







		lowerCAmelCase_				:					str				     =						"""ernie"""


		def __init__(						self    :	Optional[Any]						,		_UpperCAmelCase    :	Tuple=3_05_22						,		_UpperCAmelCase    :	int=7_68						,		_UpperCAmelCase    :	Dict=12						,		_UpperCAmelCase    :	Dict=12						,		_UpperCAmelCase    :	Union[str, Any]=30_72						,		_UpperCAmelCase    :	str="gelu"						,		_UpperCAmelCase    :	Tuple=0.1						,		_UpperCAmelCase    :	Optional[Any]=0.1						,		_UpperCAmelCase    :	Dict=5_12						,		_UpperCAmelCase    :	str=2						,		_UpperCAmelCase    :	Tuple=3						,		_UpperCAmelCase    :	Union[str, Any]=False						,		_UpperCAmelCase    :	List[str]=0.02						,		_UpperCAmelCase    :	str=1E-12						,		_UpperCAmelCase    :	List[str]=0						,		_UpperCAmelCase    :	Dict="absolute"						,		_UpperCAmelCase    :	List[str]=True						,		_UpperCAmelCase    :	Optional[Any]=None						,		**_UpperCAmelCase    :	int						,		):






			"""simple docstring"""






			super().__init__(pad_token_id=__snake_case						,		**__snake_case )

			UpperCAmelCase__										=    vocab_size
			UpperCAmelCase__										=    hidden_size
			UpperCAmelCase__										=    num_hidden_layers
			UpperCAmelCase__										=    num_attention_heads
			UpperCAmelCase__										=    hidden_act
			UpperCAmelCase__										=    intermediate_size
			UpperCAmelCase__										=    hidden_dropout_prob
			UpperCAmelCase__										=    attention_probs_dropout_prob
			UpperCAmelCase__										=    max_position_embeddings
			UpperCAmelCase__										=    type_vocab_size
			UpperCAmelCase__										=    task_type_vocab_size
			UpperCAmelCase__										=    use_task_id
			UpperCAmelCase__										=    initializer_range
			UpperCAmelCase__										=    layer_norm_eps
			UpperCAmelCase__										=    position_embedding_type
			UpperCAmelCase__										=    use_cache
			UpperCAmelCase__										=    classifier_dropout

class 						lowerCAmelCase_   ( snake_case__   ):







		'''simple docstring'''







		@property
		def 							SCREAMING_SNAKE_CASE__			(						self    :	Tuple ):






			"""simple docstring"""






			if self.task == "multiple-choice":
				UpperCAmelCase__										=    {0: """batch""", 1: """choice""", 2: """sequence"""}
			else:
				UpperCAmelCase__										=    {0: """batch""", 1: """sequence"""}
			return OrderedDict(
			    [
			        ("""input_ids""", dynamic_axis),
			        ("""attention_mask""", dynamic_axis),
			        ("""token_type_ids""", dynamic_axis),
			        ("""task_type_ids""", dynamic_axis),
			    ] )






'''simple docstring'''




import os

from apache_beam.io.filesystems import FileSystems
from apache_beam.pipeline import Pipeline

from .logging import get_logger


UpperCAmelCase_       				=      2 << 2_0  # 2mb
UpperCAmelCase_       				=      get_logger(__name__)

class 						lowerCAmelCase_   ( lowerCamelCase_   ):







  '''simple docstring'''







  def 							SCREAMING_SNAKE_CASE__			(						self    :	Any ):






   """simple docstring"""






   UpperCAmelCase__										=    self._options.get_all_options().get("""runner""" )
   return runner in [None, "DirectRunner", "PortableRunner"]

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Any       ,						SCREAMING_SNAKE_CASE__			:      List[Any]       ,						SCREAMING_SNAKE_CASE__			:      Any=False       ):
 '''simple docstring'''





 UpperCAmelCase__										=    FileSystems
 if fs.exists(SCREAMING_SNAKE_CASE__       ):
  if force_upload:
   logger.info(F'''Remote path already exist: {remote_file_path}. Overwriting it as force_upload=True.'''       )
  else:
   logger.info(F'''Remote path already exist: {remote_file_path}. Skipping it as force_upload=False.'''       )
   return
 with fs.create(SCREAMING_SNAKE_CASE__       ) as remote_file:
  with open(SCREAMING_SNAKE_CASE__       ,						"""rb"""       ) as local_file:
   UpperCAmelCase__										=    local_file.read(SCREAMING_SNAKE_CASE__       )
   while chunk:
    remote_file.write(SCREAMING_SNAKE_CASE__       )
    UpperCAmelCase__										=    local_file.read(SCREAMING_SNAKE_CASE__       )







def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Dict       ,						SCREAMING_SNAKE_CASE__			:      Any       ,						SCREAMING_SNAKE_CASE__			:      Dict=False       ):
 '''simple docstring'''





 UpperCAmelCase__										=    FileSystems
 if os.path.exists(SCREAMING_SNAKE_CASE__       ):
  if force_download:
   logger.info(F'''Local path already exist: {remote_file_path}. Overwriting it as force_upload=True.'''       )
  else:
   logger.info(F'''Local path already exist: {remote_file_path}. Skipping it as force_upload=False.'''       )
   return
 with fs.open(SCREAMING_SNAKE_CASE__       ) as remote_file:
  with open(SCREAMING_SNAKE_CASE__       ,						"""wb"""       ) as local_file:
   UpperCAmelCase__										=    remote_file.read(SCREAMING_SNAKE_CASE__       )
   while chunk:
    local_file.write(SCREAMING_SNAKE_CASE__       )
    UpperCAmelCase__										=    remote_file.read(SCREAMING_SNAKE_CASE__       )
