
'''simple docstring'''







import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry
class  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase   ):
	lowercase__	    =							"mock"
	def __init__(				self  ,    *__UpperCamelCase  ,    __UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					super().__init__()
					__a       :     int								=	LocalFileSystem(*__UpperCamelCase  ,    **__UpperCamelCase			)
					__a       :     List[Any]								=	Path(__UpperCamelCase			).resolve().as_posix() + """/"""
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     int								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.mkdir(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     List[str]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.makedirs(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.rmdir(__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase=True  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     str								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					__a       :     List[str]								=	self._fs.ls(__UpperCamelCase  ,    detail=__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
					if detail:
									return [{**info, "name": info["name"][len(self.local_root_dir			) :]} for info in out]
					else:
									return [name[len(self.local_root_dir			) :] for name in out]
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     int								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					__a       :     Tuple								=	dict(self._fs.info(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)			)
					__a       :     List[Any]								=	out["""name"""][len(self.local_root_dir			) :]
					return out
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     str								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					__a       :     List[str]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.cp_file(__UpperCamelCase  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     int								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.rm_file(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[int]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.rm(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					__a       :     Dict								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs._open(__UpperCamelCase  ,    *__UpperCamelCase  ,    **__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.created(__UpperCamelCase			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     List[str]								=	posixpath.join(self.local_root_dir  ,    self._strip_protocol(__UpperCamelCase			)			)
					return self._fs.modified(__UpperCamelCase			)

	@classmethod
	def __lowerCamelCase    (				cls  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	stringify_path(__UpperCamelCase			)
					if path.startswith("""mock://"""			):
									__a       :     Tuple								=	path[7:]
					return path







class  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase   ):
	lowercase__	    =							"tmp"
	lowercase__	    =							None
	def __init__(				self  ,    *__UpperCamelCase  ,    **__UpperCamelCase			):



					'''simple docstring'''






					assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
					super().__init__(*__UpperCamelCase  ,    **__UpperCamelCase  ,    local_root_dir=self.tmp_dir  ,    auto_mkdir=__UpperCamelCase			)

	@classmethod
	def __lowerCamelCase    (				cls  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	stringify_path(__UpperCamelCase			)
					if path.startswith("""tmp://"""			):
									__a       :     Tuple								=	path[6:]
					return path







@pytest.fixture
def 				_snake_case (		)       ->       Optional[int]:
				__a       :     Dict								=	MockFileSystem
				__a       :     Tuple								=	TmpDirFileSystem
				yield
				del _fsspec_registry["mock"]
				del _fsspec_registry["tmp"]

@pytest.fixture
def 				_snake_case (		lowercase			,    lowercase						)       ->       Tuple:
				__a       :     Any								=	tmp_path_factory.mktemp("""mockfs"""						)
				return MockFileSystem(local_root_dir=lowercase			,    auto_mkdir=lowercase						)

@pytest.fixture
def 				_snake_case (		lowercase			,    lowercase						)       ->       List[Any]:
				__a       :     str								=	tmp_path_factory.mktemp("""tmpfs"""						)
				with patch.object(lowercase			,    """tmp_dir"""			,    lowercase						):
								yield TmpDirFileSystem()

'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__SCREAMING_SNAKE_CASE		:  Tuple        =      {
    'configuration_segformer': ['SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SegformerConfig', 'SegformerOnnxConfig']
}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  Dict        =      ['SegformerFeatureExtractor']
					__SCREAMING_SNAKE_CASE		:  str        =      ['SegformerImageProcessor']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  List[str]        =      [
					    'SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'SegformerDecodeHead',
					    'SegformerForImageClassification',
					    'SegformerForSemanticSegmentation',
					    'SegformerLayer',
					    'SegformerModel',
					    'SegformerPreTrainedModel',
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  List[str]        =      [
					    'TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'TFSegformerDecodeHead',
					    'TFSegformerForImageClassification',
					    'TFSegformerForSemanticSegmentation',
					    'TFSegformerModel',
					    'TFSegformerPreTrainedModel',
					]


if TYPE_CHECKING:
					from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .feature_extraction_segformer import SegformerFeatureExtractor
										from .image_processing_segformer import SegformerImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_segformer import (
										    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    SegformerDecodeHead,
										    SegformerForImageClassification,
										    SegformerForSemanticSegmentation,
										    SegformerLayer,
										    SegformerModel,
										    SegformerPreTrainedModel,
										)
					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_segformer import (
										    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFSegformerDecodeHead,
										    TFSegformerForImageClassification,
										    TFSegformerForSemanticSegmentation,
										    TFSegformerModel,
										    TFSegformerPreTrainedModel,
										)

else:
					import sys

					__SCREAMING_SNAKE_CASE		:  Optional[Any]        =      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)