



from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__						:	Optional[Any]					=logging.get_logger(__name__)

lowerCAmelCase__						:	Dict					={
    "alibaba-damo/mgp-str-base": "https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json",
}

class   UpperCAmelCase_    (  lowerCAmelCase__			):

						'''simple docstring'''




						UpperCamelCase__     :					List[Any]							    =    """mgp-str"""






						def __init__(       self ,				_A=[32, 128] ,				_A=4 ,				_A=3 ,				_A=27 ,				_A=38 ,				_A=50_257 ,				_A=30_522 ,				_A=768 ,				_A=12 ,				_A=12 ,				_A=4.0 ,				_A=True ,				_A=False ,				_A=1e-5 ,				_A=0.0 ,				_A=0.0 ,				_A=0.0 ,				_A=False ,				_A=0.0_2 ,				**_A ,				):







													'''simple docstring'''

													super().__init__(**__a						)

													__SCREAMING_SNAKE_CASE										=   image_size
													__SCREAMING_SNAKE_CASE										=   patch_size
													__SCREAMING_SNAKE_CASE										=   num_channels
													__SCREAMING_SNAKE_CASE										=   max_token_length
													__SCREAMING_SNAKE_CASE										=   num_character_labels
													__SCREAMING_SNAKE_CASE										=   num_bpe_labels
													__SCREAMING_SNAKE_CASE										=   num_wordpiece_labels
													__SCREAMING_SNAKE_CASE										=   hidden_size
													__SCREAMING_SNAKE_CASE										=   num_hidden_layers
													__SCREAMING_SNAKE_CASE										=   num_attention_heads
													__SCREAMING_SNAKE_CASE										=   mlp_ratio
													__SCREAMING_SNAKE_CASE										=   distilled
													__SCREAMING_SNAKE_CASE										=   layer_norm_eps
													__SCREAMING_SNAKE_CASE										=   drop_rate
													__SCREAMING_SNAKE_CASE										=   qkv_bias
													__SCREAMING_SNAKE_CASE										=   attn_drop_rate
													__SCREAMING_SNAKE_CASE										=   drop_path_rate
													__SCREAMING_SNAKE_CASE										=   output_aa_attentions
													__SCREAMING_SNAKE_CASE										=   initializer_range










"""simple docstring"""


from pathlib import PurePosixPath
from typing import Optional

import fsspec
from fsspec import AbstractFileSystem
from huggingface_hub.hf_api import DatasetInfo

from ..utils.file_utils import get_authentication_headers_for_url
from ..utils.hub import hf_hub_url
class     _UpperCamelCase    (  lowerCAmelCase__						):
							'''simple docstring'''







							__UpperCAmelCase		:       Union[str, Any]							 =""""""
							__UpperCAmelCase		:       Optional[int]							 ="""hf-legacy"""  # "hf://"" is reserved for hffs

							def __init__(	self       ,  __a = None       ,  __a = None       ,  **__a       ,  ):
										super().__init__(self       ,  **__a      )
										__lowerCAmelCase							       =     repo_info
										__lowerCAmelCase							       =     token
										__lowerCAmelCase							       =     None

							def      snake_case							(	self      ):
										if self.dir_cache is None:
													__lowerCAmelCase							       =     {}
													for hf_file in self.repo_info.siblings:
																# TODO(QL): add sizes
																__lowerCAmelCase							       =     {
																    "name": hf_file.rfilename,
																    "size": None,
																    "type": "file",
																}
																self.dir_cache.update(
																    {
																        str(__a      ): {"name": str(__a      ), "size": None, "type": "directory"}
																        for d in list(PurePosixPath(hf_file.rfilename      ).parents      )[:-1]
																    }      )

							def      snake_case							(	self       ,  __a       ,  __a = "rb"       ,  **__a       ,  ):
										if not isinstance(self.repo_info       ,  __a      ):
													raise NotImplementedError(f"Open is only implemented for dataset repositories, but got {self.repo_info}"      )
										__lowerCAmelCase							       =     hf_hub_url(self.repo_info.id       ,  __a       ,  revision=self.repo_info.sha      )
										return fsspec.open(
										    __a       ,  mode=__a       ,  headers=get_authentication_headers_for_url(__a       ,  use_auth_token=self.token      )       ,  client_kwargs={"trust_env": True}       ,  ).open()

							def      snake_case							(	self       ,  __a       ,  **__a      ):
										self._get_dirs()
										__lowerCAmelCase							       =     self._strip_protocol(__a      )
										if path in self.dir_cache:
													return self.dir_cache[path]
										else:
													raise FileNotFoundError(__a      )



							def      snake_case							(	self       ,  __a       ,  __a=False       ,  **__a      ):
										self._get_dirs()
										__lowerCAmelCase							       =     PurePosixPath(path.strip("/"      )      )
										__lowerCAmelCase							       =     {}
										for p, f in self.dir_cache.items():
													__lowerCAmelCase							       =     PurePosixPath(p.strip("/"      )      )
													__lowerCAmelCase							       =     p.parent
													if root == path:
																__lowerCAmelCase							       =     f
										__lowerCAmelCase							       =     list(paths.values()      )
										if detail:
													return out
										else:
													return sorted(f["name"] for f in out      )




