code: import unittest
  from unittest.util import safe_repr
  
  from transformers import AutoTokenizer, RwkvConfig, is_torch_available
  from transformers.testing_utils import require_torch, slow, torch_device
  
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_torch_available():
  		import torch
  
  		from transformers import (
  		    RWKV_PRETRAINED_MODEL_ARCHIVE_LIST,
  		    RwkvForCausalLM,
  		    RwkvModel,
  		)
  		from transformers.pytorch_utils import is_torch_greater_or_equal_than_2_0
  else:
  		lowerCamelCase__           =				False
  
  
  
  
  class 					UpperCamelCase	:
  
  
  
  
  					def __init__( self :					Any      ,_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					Any=14      ,_lowerCAmelCase :					str=7      ,_lowerCAmelCase :					Optional[Any]=True      ,_lowerCAmelCase :					int=False      ,_lowerCAmelCase :					int=True      ,_lowerCAmelCase :					Dict=True      ,_lowerCAmelCase :					Optional[int]=True      ,_lowerCAmelCase :					Tuple=99      ,_lowerCAmelCase :					List[Any]=32      ,_lowerCAmelCase :					str=5      ,_lowerCAmelCase :					str=37      ,_lowerCAmelCase :					Union[str, Any]="gelu"      ,_lowerCAmelCase :					Union[str, Any]=0.1      ,_lowerCAmelCase :					Union[str, Any]=0.1      ,_lowerCAmelCase :					Union[str, Any]=512      ,_lowerCAmelCase :					Union[str, Any]=16      ,_lowerCAmelCase :					Tuple=2      ,_lowerCAmelCase :					int=3      ,_lowerCAmelCase :					Union[str, Any]=4      ,_lowerCAmelCase :					Union[str, Any]=None      ,):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     parent
  							__snake_case		       =     batch_size
  							__snake_case		       =     seq_length
  							__snake_case		       =     is_training
  							__snake_case		       =     use_token_type_ids
  							__snake_case		       =     use_input_mask
  							__snake_case		       =     use_labels
  							__snake_case		       =     use_mc_token_ids
  							__snake_case		       =     vocab_size
  							__snake_case		       =     hidden_size
  							__snake_case		       =     num_hidden_layers
  							__snake_case		       =     intermediate_size
  							__snake_case		       =     hidden_act
  							__snake_case		       =     hidden_dropout_prob
  							__snake_case		       =     attention_probs_dropout_prob
  							__snake_case		       =     max_position_embeddings
  							__snake_case		       =     type_vocab_size
  							__snake_case		       =     type_sequence_label_size
  							__snake_case		       =     num_labels
  							__snake_case		       =     num_choices
  							__snake_case		       =     scope
  							__snake_case		       =     vocab_size - 1
  							__snake_case		       =     vocab_size - 1
  							__snake_case		       =     vocab_size - 1
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							return RwkvConfig.from_pretrained("sgugger/rwkv-4-pile-7b"						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					str      ,_lowerCAmelCase :					List[Any]=False      ,_lowerCAmelCase :					Optional[Any]=False      ,_lowerCAmelCase :					str=False						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     ids_tensor([self.batch_size, self.seq_length]      ,self.vocab_size						)
  
  							__snake_case		       =     None
  							if self.use_input_mask:
  									__snake_case		       =     random_attention_mask([self.batch_size, self.seq_length]						)
  
  							__snake_case		       =     None
  							if self.use_token_type_ids:
  									__snake_case		       =     ids_tensor([self.batch_size, self.seq_length]      ,self.type_vocab_size						)
  
  							__snake_case		       =     None
  							if self.use_mc_token_ids:
  									__snake_case		       =     ids_tensor([self.batch_size, self.num_choices]      ,self.seq_length						)
  
  							__snake_case		       =     None
  							__snake_case		       =     None
  							__snake_case		       =     None
  							if self.use_labels:
  									__snake_case		       =     ids_tensor([self.batch_size]      ,self.type_sequence_label_size						)
  									__snake_case		       =     ids_tensor([self.batch_size, self.seq_length]      ,self.num_labels						)
  									__snake_case		       =     ids_tensor([self.batch_size]      ,self.num_choices						)
  
  							__snake_case		       =     self.get_config(
  							    gradient_checkpointing=_lowerCAmelCase      ,scale_attn_by_inverse_layer_idx=_lowerCAmelCase      ,reorder_and_upcast_attn=_lowerCAmelCase      ,)
  
  							return (
  							    config,
  							    input_ids,
  							    input_mask,
  							    None,
  							    token_type_ids,
  							    mc_token_ids,
  							    sequence_labels,
  							    token_labels,
  							    choice_labels,
  							)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Dict      ,_lowerCAmelCase :					Any=False      ,_lowerCAmelCase :					Tuple=False      ,_lowerCAmelCase :					Union[str, Any]=False						):
  
  
  							"""simple docstring"""
  
  
  
  
  							return RwkvConfig(
  							    vocab_size=self.vocab_size      ,hidden_size=self.hidden_size      ,num_hidden_layers=self.num_hidden_layers      ,intermediate_size=self.intermediate_size      ,activation_function=self.hidden_act      ,resid_pdrop=self.hidden_dropout_prob      ,attn_pdrop=self.attention_probs_dropout_prob      ,n_positions=self.max_position_embeddings      ,type_vocab_size=self.type_vocab_size      ,use_cache=_lowerCAmelCase      ,bos_token_id=self.bos_token_id      ,eos_token_id=self.eos_token_id      ,pad_token_id=self.pad_token_id      ,gradient_checkpointing=_lowerCAmelCase      ,scale_attn_by_inverse_layer_idx=_lowerCAmelCase      ,reorder_and_upcast_attn=_lowerCAmelCase      ,)
  
  
  
  
  					def 							UpperCamelCase_						( self :					int						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     self.get_config()
  							__snake_case		       =     300
  							return config
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							(
  							    (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       
  							)		       =     self.prepare_config_and_inputs()
  
  							__snake_case		       =     floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
  							__snake_case		       =     ids_tensor([self.batch_size, self.seq_length]      ,vocab_size=2						)
  
  							return (
  							    config,
  							    input_ids,
  							    input_mask,
  							    head_mask,
  							    token_type_ids,
  							    sequence_labels,
  							    token_labels,
  							    choice_labels,
  							    encoder_hidden_states,
  							    encoder_attention_mask,
  							)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[Any]      ,_lowerCAmelCase :					Tuple      ,_lowerCAmelCase :					Union[str, Any]      ,_lowerCAmelCase :					Tuple      ,_lowerCAmelCase :					str      ,_lowerCAmelCase :					List[str]      ,*_lowerCAmelCase :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     True
  							__snake_case		       =     RwkvModel(config=_lowerCAmelCase						)
  							model.to(_lowerCAmelCase						)
  							model.eval()
  
  							__snake_case		       =     model(_lowerCAmelCase						)
  
  							self.parent.assertEqual(result.last_hidden_state.shape      ,(self.batch_size, self.seq_length, self.hidden_size)						)
  							self.parent.assertEqual(len(result.hidden_states						)      ,config.num_hidden_layers + 1						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Any      ,_lowerCAmelCase :					Optional[Any]      ,_lowerCAmelCase :					List[Any]      ,_lowerCAmelCase :					Dict      ,_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					List[str]      ,*_lowerCAmelCase :					Dict						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     RwkvForCausalLM(_lowerCAmelCase						)
  							model.to(_lowerCAmelCase						)
  							model.eval()
  
  							__snake_case		       =     model(_lowerCAmelCase      ,labels=_lowerCAmelCase						)
  							self.parent.assertEqual(result.loss.shape      ,()						)
  							self.parent.assertEqual(result.logits.shape      ,(self.batch_size, self.seq_length, self.vocab_size)						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[int]      ,_lowerCAmelCase :					str      ,_lowerCAmelCase :					Optional[Any]      ,_lowerCAmelCase :					Dict      ,_lowerCAmelCase :					Union[str, Any]      ,_lowerCAmelCase :					str      ,*_lowerCAmelCase :					str						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     RwkvModel(config=_lowerCAmelCase						)
  							model.to(_lowerCAmelCase						)
  							model.eval()
  
  							__snake_case		       =     model(_lowerCAmelCase						)
  							__snake_case		       =     outputs.last_hidden_state
  
  							__snake_case		       =     model(input_ids[:, :2]						)
  							__snake_case		       =     outputs.last_hidden_state
  
  							# Using the state computed on the first inputs, we will get the same output
  							__snake_case		       =     model(input_ids[:, 2:]      ,state=outputs.state						)
  							__snake_case		       =     outputs.last_hidden_state
  
  							self.parent.assertTrue(torch.allclose(torch.cat([output_one, output_two]      ,dim=1						)      ,_lowerCAmelCase      ,atol=1E-5						)						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Tuple      ,_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					List[str]      ,_lowerCAmelCase :					Any      ,_lowerCAmelCase :					Optional[Any]      ,_lowerCAmelCase :					Any      ,*_lowerCAmelCase :					Any      ,_lowerCAmelCase :					int=False						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     RwkvForCausalLM(_lowerCAmelCase						)
  							model.to(_lowerCAmelCase						)
  							if gradient_checkpointing:
  									model.gradient_checkpointing_enable()
  
  							__snake_case		       =     model(_lowerCAmelCase      ,labels=_lowerCAmelCase						)
  							self.parent.assertEqual(result.loss.shape      ,()						)
  							self.parent.assertEqual(result.logits.shape      ,(self.batch_size, self.seq_length, self.vocab_size)						)
  							result.loss.backward()
  
  
  
  
  
  
  
  					def 							UpperCamelCase_						( self :					List[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     self.prepare_config_and_inputs()
  
  							(
  							    (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       (
  							    __snake_case
  							)       ,       
  							)		       =     config_and_inputs
  
  							__snake_case		       =     {"input_ids": input_ids}
  
  							return config, inputs_dict
  
  
  
  
  @unittest.skipIf(
      not is_torch_greater_or_equal_than_2_0			,      reason="""See https://github.com/huggingface/transformers/pull/24204"""      )
  @require_torch
  class 					UpperCamelCase	(     snake_case__			,      snake_case__			,      snake_case__			,      unittest.TestCase      ):
  					__UpperCamelCase						=   (RwkvModel, RwkvForCausalLM) if is_torch_available() else ()
  					__UpperCamelCase						=   (
  					    {"""feature-extraction""": RwkvModel, """text-generation""": RwkvForCausalLM} if is_torch_available() else {}
  					)
  					# all_generative_model_classes = (RwkvForCausalLM,) if is_torch_available() else ()
  					__UpperCamelCase						=   False
  					__UpperCamelCase						=   False
  					__UpperCamelCase						=   False
  					__UpperCamelCase						=   False
  					__UpperCamelCase						=   False  # Rwkv does not support head masking
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     RwkvModelTester(self						)
  							__snake_case		       =     ConfigTester(
  							    self      ,config_class=_lowerCAmelCase      ,n_embd=37      ,common_properties=["hidden_size", "num_hidden_layers"]						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Tuple      ,_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					Optional[Any]      ,_lowerCAmelCase :					Union[str, Any]=None						):
  
  
  							"""simple docstring"""
  
  
  
  
  							if isinstance(_lowerCAmelCase      ,torch.Tensor						):
  									__snake_case       ,       __snake_case		       =     member.max().item(), member.min().item()
  							elif isinstance(_lowerCAmelCase      ,_lowerCAmelCase						) or isinstance(_lowerCAmelCase      ,_lowerCAmelCase						):
  									__snake_case       ,       __snake_case		       =     max(_lowerCAmelCase						), min(_lowerCAmelCase						)
  
  							if not isinstance(_lowerCAmelCase      ,_lowerCAmelCase						):
  									raise TypeError("container should be a list or tuple"						)
  							elif len(_lowerCAmelCase						) != 2:
  									raise ValueError("container should have 2 elements"						)
  
  							__snake_case       ,       __snake_case		       =     container
  
  							__snake_case		       =     (min_value >= expected_min) and (max_value <= expected_max)
  
  							if not is_inside_interval:
  									__snake_case		       =     "%s not found in %s" % (safe_repr(_lowerCAmelCase						), safe_repr(_lowerCAmelCase						))
  									self.fail(self._formatMessage(_lowerCAmelCase      ,_lowerCAmelCase						)						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[int]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							self.config_tester.run_common_tests()
  
  
  
  
  					def 							UpperCamelCase_						( self :					List[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     self.model_tester.prepare_config_and_inputs()
  							self.model_tester.create_and_check_rwkv_model(*_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Any						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     self.model_tester.prepare_config_and_inputs()
  							self.model_tester.create_and_check_causl_lm(*_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					str						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     self.model_tester.prepare_config_and_inputs()
  							self.model_tester.create_and_check_state_equivalency(*_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case       ,       __snake_case		       =     self.model_tester.prepare_config_and_inputs_for_common()
  
  							for model_class in self.all_model_classes:
  									__snake_case		       =     model_class(config=_lowerCAmelCase						)
  									for name, param in model.named_parameters():
  											if "time_decay" in name:
  													if param.requires_grad:
  															self.assertTrue(param.data.max().item() == 3.0						)
  															self.assertTrue(param.data.min().item() == -5.0						)
  											elif "time_first" in name:
  													if param.requires_grad:
  															# check if it's a ones like
  															self.assertTrue(torch.allclose(param.data      ,torch.ones_like(param.data						)      ,atol=1E-5      ,rtol=1E-5						)						)
  											elif any(x in name for x in ["time_mix_key", "time_mix_receptance"]						):
  													if param.requires_grad:
  															self.assertInterval(
  															    param.data      ,[0.0, 1.0]      ,msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""      ,)
  											elif "time_mix_value" in name:
  													if param.requires_grad:
  															self.assertInterval(
  															    param.data      ,[0.0, 1.3]      ,msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""      ,)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case       ,       __snake_case		       =     self.model_tester.prepare_config_and_inputs_for_common()
  							__snake_case		       =     True
  
  							__snake_case		       =     getattr(self.model_tester      ,"seq_length"      ,_lowerCAmelCase						)
  
  							for model_class in self.all_model_classes:
  									__snake_case		       =     True
  									__snake_case		       =     False
  									__snake_case		       =     True
  									__snake_case		       =     model_class(_lowerCAmelCase						)
  									model.to(_lowerCAmelCase						)
  									model.eval()
  
  									__snake_case		       =     self._prepare_for_class(_lowerCAmelCase      ,_lowerCAmelCase						)
  									__snake_case		       =     inputs["input_ids"].shape[0]
  									with torch.no_grad():
  											__snake_case		       =     model(**_lowerCAmelCase						)
  									__snake_case		       =     outputs.attentions
  									self.assertEqual(len(_lowerCAmelCase						)      ,self.model_tester.num_hidden_layers						)
  
  									# check that output_attentions also work using config
  									del inputs_dict["output_attentions"]
  									__snake_case		       =     True
  									__snake_case		       =     model_class(_lowerCAmelCase						)
  									model.to(_lowerCAmelCase						)
  									model.eval()
  
  									__snake_case		       =     self._prepare_for_class(_lowerCAmelCase      ,_lowerCAmelCase						)
  									__snake_case		       =     inputs["input_ids"].shape[0]
  									with torch.no_grad():
  											__snake_case		       =     model(**_lowerCAmelCase						)
  									__snake_case		       =     outputs.attentions
  									self.assertEqual(len(_lowerCAmelCase						)      ,self.model_tester.num_hidden_layers						)
  
  									self.assertListEqual(
  									    list(attentions[0].shape[-3:]						)      ,[batch_size, seq_len, config.hidden_size]      ,)
  									__snake_case		       =     len(_lowerCAmelCase						)
  
  									# Check attention is always last and order is fine
  									__snake_case		       =     True
  									__snake_case		       =     True
  									__snake_case		       =     model_class(_lowerCAmelCase						)
  									model.to(_lowerCAmelCase						)
  									model.eval()
  
  									__snake_case		       =     self._prepare_for_class(_lowerCAmelCase      ,_lowerCAmelCase						)
  									__snake_case		       =     inputs["input_ids"].shape[0]
  									with torch.no_grad():
  											__snake_case		       =     model(**_lowerCAmelCase						)
  
  									__snake_case		       =     1
  									self.assertEqual(out_len + added_hidden_states      ,len(_lowerCAmelCase						)						)
  
  									__snake_case		       =     outputs.attentions
  
  									self.assertEqual(len(_lowerCAmelCase						)      ,self.model_tester.num_hidden_layers						)
  									self.assertListEqual(
  									    list(self_attentions[0].shape[-3:]						)      ,[batch_size, seq_len, config.hidden_size]      ,)
  
  
  
  
  
  
  
  					@slow
  					def 							UpperCamelCase_						( self :					List[str]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							for model_name in RWKV_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  									__snake_case		       =     RwkvModel.from_pretrained(_lowerCAmelCase						)
  									self.assertIsNotNone(_lowerCAmelCase						)
  
  
  
  
  @unittest.skipIf(
      not is_torch_greater_or_equal_than_2_0			,      reason="""See https://github.com/huggingface/transformers/pull/24204"""      )
  @slow
  class 					UpperCamelCase	(     unittest.TestCase      ):
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[int]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     "RWKV/rwkv-4-169m-pile"
  							__snake_case		       =     AutoTokenizer.from_pretrained(self.model_id						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     "Hello my name is Jasmine and I am a newbie to the"
  							__snake_case		       =     RwkvForCausalLM.from_pretrained(self.model_id						).to(_lowerCAmelCase						)
  
  							__snake_case		       =     self.tokenizer("Hello my name is"      ,return_tensors="pt"						).input_ids.to(_lowerCAmelCase						)
  							__snake_case		       =     model.generate(_lowerCAmelCase      ,max_new_tokens=10						)
  							__snake_case		       =     self.tokenizer.decode(output[0].tolist()						)
  
  							self.assertEqual(_lowerCAmelCase      ,_lowerCAmelCase						)
  
  
  
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     "Hello my name is Jasmine and I am a newbie to the"
  
  							__snake_case		       =     self.tokenizer("Hello my name is"      ,return_tensors="pt"						).input_ids.to(_lowerCAmelCase						)
  							__snake_case		       =     RwkvForCausalLM.from_pretrained(self.model_id      ,torch_dtype=torch.bfloataa						).to(_lowerCAmelCase						)
  
  							__snake_case		       =     model.generate(_lowerCAmelCase      ,max_new_tokens=10						)
  							__snake_case		       =     self.tokenizer.decode(output[0].tolist()						)
  
  							self.assertEqual(_lowerCAmelCase      ,_lowerCAmelCase						)
  
  
  
  
  
  
style_context: 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 					UpperCamelCase	(     snake_case__      ):
  					__UpperCamelCase						=   """mock"""
  
  
  
  
  					def __init__( self :					List[Any]      ,*_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					Union[str, Any]      ,**_lowerCAmelCase :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							super().__init__()
  							__snake_case		       =     LocalFileSystem(*_lowerCAmelCase      ,**_lowerCAmelCase						)
  							__snake_case		       =     Path(_lowerCAmelCase						).resolve().as_posix() + "/"
  
  
  
  
  					def 							UpperCamelCase_						( self :					List[Any]      ,_lowerCAmelCase :					Optional[Any]      ,*_lowerCAmelCase :					Union[str, Any]      ,**_lowerCAmelCase :					Dict						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.mkdir(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					int      ,_lowerCAmelCase :					Tuple      ,*_lowerCAmelCase :					Optional[Any]      ,**_lowerCAmelCase :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.makedirs(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Tuple      ,_lowerCAmelCase :					Any						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.rmdir(_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					List[Any]      ,_lowerCAmelCase :					List[Any]      ,_lowerCAmelCase :					str=True      ,*_lowerCAmelCase :					int      ,**_lowerCAmelCase :					List[str]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							__snake_case		       =     self._fs.ls(_lowerCAmelCase      ,detail=_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  							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 							UpperCamelCase_						( self :					List[str]      ,_lowerCAmelCase :					Any      ,*_lowerCAmelCase :					Any      ,**_lowerCAmelCase :					str						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							__snake_case		       =     dict(self._fs.info(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)						)
  							__snake_case		       =     out["name"][len(self.local_root_dir						) :]
  							return out
  
  
  
  
  					def 							UpperCamelCase_						( self :					Tuple      ,_lowerCAmelCase :					Optional[int]      ,_lowerCAmelCase :					Optional[Any]      ,*_lowerCAmelCase :					int      ,**_lowerCAmelCase :					Optional[int]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.cp_file(_lowerCAmelCase      ,_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]      ,_lowerCAmelCase :					int      ,*_lowerCAmelCase :					List[Any]      ,**_lowerCAmelCase :					int						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.rm_file(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Optional[Any]      ,_lowerCAmelCase :					str      ,*_lowerCAmelCase :					Optional[int]      ,**_lowerCAmelCase :					int						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.rm(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					int      ,_lowerCAmelCase :					Optional[int]      ,*_lowerCAmelCase :					str      ,**_lowerCAmelCase :					Optional[Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs._open(_lowerCAmelCase      ,*_lowerCAmelCase      ,**_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]      ,_lowerCAmelCase :					Tuple						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.created(_lowerCAmelCase						)
  
  
  
  
  					def 							UpperCamelCase_						( self :					Union[str, Any]      ,_lowerCAmelCase :					int						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     posixpath.join(self.local_root_dir      ,self._strip_protocol(_lowerCAmelCase						)						)
  							return self._fs.modified(_lowerCAmelCase						)
  
  
  
  
  
  
  
  					@classmethod
  					def 							UpperCamelCase_						( cls :					Dict      ,_lowerCAmelCase :					Dict						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     stringify_path(_lowerCAmelCase						)
  							if path.startswith("mock://"						):
  									__snake_case		       =     path[7:]
  							return path
  
  
  
  
  class 					UpperCamelCase	(     snake_case__      ):
  					__UpperCamelCase						=   """tmp"""
  					__UpperCamelCase						=   None
  
  
  
  
  					def __init__( self :					int      ,*_lowerCAmelCase :					Tuple      ,**_lowerCAmelCase :					Union[str, Any]						):
  
  
  							"""simple docstring"""
  
  
  
  
  							assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
  							super().__init__(*_lowerCAmelCase      ,**_lowerCAmelCase      ,local_root_dir=self.tmp_dir      ,auto_mkdir=_lowerCAmelCase						)
  
  
  
  
  
  
  
  					@classmethod
  					def 							UpperCamelCase_						( cls :					int      ,_lowerCAmelCase :					str						):
  
  
  							"""simple docstring"""
  
  
  
  
  							__snake_case		       =     stringify_path(_lowerCAmelCase						)
  							if path.startswith("tmp://"						):
  									__snake_case		       =     path[6:]
  							return path
  
  
  
  
  @pytest.fixture
  def 							_lowerCamelCase(				)  ->   str:
  		__snake_case		       =     MockFileSystem
  		__snake_case		       =     TmpDirFileSystem
  		yield
  		del _fsspec_registry["mock"]
  		del _fsspec_registry["tmp"]
  
  
  
  @pytest.fixture
  def 							_lowerCamelCase(				__snake_case						,						__snake_case	)  ->   Dict:
  		__snake_case		       =     tmp_path_factory.mktemp("mockfs"	)
  		return MockFileSystem(local_root_dir=__snake_case						,						auto_mkdir=__snake_case	)
  
  
  
  
  
  @pytest.fixture
  def 							_lowerCamelCase(				__snake_case						,						__snake_case	)  ->   List[Any]:
  		__snake_case		       =     tmp_path_factory.mktemp("tmpfs"	)
  		with patch.object(__snake_case						,						"tmp_dir"						,						__snake_case	):
  				yield TmpDirFileSystem()
  
  
  
  
  
  