
import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch
							from torch import nn

							from transformers import (
							    MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
							    VideoMAEForPreTraining,
							    VideoMAEForVideoClassification,
							    VideoMAEModel,
							)
							from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
							from transformers import VideoMAEImageProcessor

class     _UpperCamelCase			:






			'''simple docstring'''

			def __init__(    self	:    Tuple  ,		snake_case_	:    Optional[Any]  ,		snake_case_	:    List[str]=13  ,		snake_case_	:    Union[str, Any]=10  ,		snake_case_	:    Optional[Any]=3  ,		snake_case_	:    Optional[Any]=2  ,		snake_case_	:    Optional[int]=2  ,		snake_case_	:    int=2  ,		snake_case_	:    Tuple=True  ,		snake_case_	:    Optional[Any]=True  ,		snake_case_	:    str=32  ,		snake_case_	:    Tuple=5  ,		snake_case_	:    Union[str, Any]=4  ,		snake_case_	:    Dict=37  ,		snake_case_	:    Tuple="gelu"  ,		snake_case_	:    str=0.1  ,		snake_case_	:    Optional[int]=0.1  ,		snake_case_	:    Optional[int]=10  ,		snake_case_	:    List[Any]=0.02  ,		snake_case_	:    Dict=0.9  ,		snake_case_	:    List[Any]=None  ,		):
							UpperCamelCase_:							int		=  parent
							UpperCamelCase_:							Union[str, Any]		=  batch_size
							UpperCamelCase_:							Union[str, Any]		=  image_size
							UpperCamelCase_:							Tuple		=  num_channels
							UpperCamelCase_:							Any		=  patch_size
							UpperCamelCase_:							Union[str, Any]		=  tubelet_size
							UpperCamelCase_:							List[Any]		=  num_frames
							UpperCamelCase_:							Optional[int]		=  is_training
							UpperCamelCase_:							Tuple		=  use_labels
							UpperCamelCase_:							Any		=  hidden_size
							UpperCamelCase_:							Optional[int]		=  num_hidden_layers
							UpperCamelCase_:							Optional[int]		=  num_attention_heads
							UpperCamelCase_:							Any		=  intermediate_size
							UpperCamelCase_:							Union[str, Any]		=  hidden_act
							UpperCamelCase_:							List[str]		=  hidden_dropout_prob
							UpperCamelCase_:							List[Any]		=  attention_probs_dropout_prob
							UpperCamelCase_:							Any		=  type_sequence_label_size
							UpperCamelCase_:							Optional[int]		=  initializer_range
							UpperCamelCase_:							str		=  mask_ratio
							UpperCamelCase_:							Dict		=  scope

							# in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
							UpperCamelCase_:							Any		=  (image_size // patch_size) ** 2
							UpperCamelCase_:							Optional[int]		=  (num_frames // tubelet_size) * self.num_patches_per_frame

							# use this variable to define bool_masked_pos
							UpperCamelCase_:							Tuple		=  int(mask_ratio * self.seq_length )

			def  lowerCAmelCase__		(    self	:    List[str] ):
							UpperCamelCase_:							Optional[Any]		=  floats_tensor(
							    [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size] )

							UpperCamelCase_:							Tuple		=  None
							if self.use_labels:
											UpperCamelCase_:							Any		=  ids_tensor([self.batch_size]  ,		self.type_sequence_label_size )

							UpperCamelCase_:							int		=  self.get_config()

							return config, pixel_values, labels

			def  lowerCAmelCase__		(    self	:    List[Any] ):
							return VideoMAEConfig(
							    image_size=self.image_size  ,		patch_size=self.patch_size  ,		num_channels=self.num_channels  ,		num_frames=self.num_frames  ,		tubelet_size=self.tubelet_size  ,		hidden_size=self.hidden_size  ,		num_hidden_layers=self.num_hidden_layers  ,		num_attention_heads=self.num_attention_heads  ,		intermediate_size=self.intermediate_size  ,		hidden_act=self.hidden_act  ,		hidden_dropout_prob=self.hidden_dropout_prob  ,		attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,		is_decoder=snake_case_  ,		initializer_range=self.initializer_range  ,		)

			def  lowerCAmelCase__		(    self	:    Union[str, Any]  ,		snake_case_	:    Optional[Any]  ,		snake_case_	:    Any  ,		snake_case_	:    str ):
							UpperCamelCase_:							List[Any]		=  VideoMAEModel(config=snake_case_ )
							model.to(snake_case_ )
							model.eval()
							UpperCamelCase_:							Tuple		=  model(snake_case_ )
							self.parent.assertEqual(result.last_hidden_state.shape  ,		(self.batch_size, self.seq_length, self.hidden_size) )

			def  lowerCAmelCase__		(    self	:    Dict  ,		snake_case_	:    List[str]  ,		snake_case_	:    List[Any]  ,		snake_case_	:    Tuple ):
							UpperCamelCase_:							Tuple		=  VideoMAEForPreTraining(snake_case_ )
							model.to(snake_case_ )
							model.eval()
							# important: each video needs to have the same number of masked patches
							# hence we define a single mask, which we then repeat for each example in the batch
							UpperCamelCase_:							Union[str, Any]		=  torch.ones((self.num_masks,) )
							UpperCamelCase_:							Optional[Any]		=  torch.cat([mask, torch.zeros(self.seq_length - mask.size(0 ) )] )
							UpperCamelCase_:							Any		=  mask.expand(self.batch_size  ,		-1 ).bool()

							UpperCamelCase_:							List[Any]		=  model(snake_case_  ,		snake_case_ )
							# model only returns predictions for masked patches
							UpperCamelCase_:							Optional[Any]		=  mask.sum().item()
							UpperCamelCase_:							str		=  3 * self.tubelet_size * self.patch_size**2
							self.parent.assertEqual(result.logits.shape  ,		(self.batch_size, num_masked_patches, decoder_num_labels) )




			def  lowerCAmelCase__		(    self	:    Optional[Any] ):
							UpperCamelCase_:							Dict		=  self.prepare_config_and_inputs()
							UpperCamelCase_,				UpperCamelCase_,				UpperCamelCase_:							Union[str, Any]		=  config_and_inputs
							UpperCamelCase_:							int		=  {"""pixel_values""": pixel_values}
							return config, inputs_dict




@require_torch
class     _UpperCamelCase			(   _A       ,    _A       ,    unittest.TestCase					):






			'''simple docstring'''

			__UpperCamelCase :  List[str]    =	(
			    (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
			)
			__UpperCamelCase :  Union[str, Any]    =	(
			    {"""feature-extraction""": VideoMAEModel, """video-classification""": VideoMAEForVideoClassification}
			    if is_torch_available()
			    else {}
			)

			__UpperCamelCase :  List[Any]    =	False
			__UpperCamelCase :  str    =	False
			__UpperCamelCase :  Union[str, Any]    =	False
			__UpperCamelCase :  int    =	False

			def  lowerCAmelCase__		(    self	:    Dict ):
							UpperCamelCase_:							Any		=  VideoMAEModelTester(self )
							UpperCamelCase_:							int		=  ConfigTester(self  ,		config_class=snake_case_  ,		has_text_modality=snake_case_  ,		hidden_size=37 )

			def  lowerCAmelCase__		(    self	:    Tuple  ,		snake_case_	:    Optional[int]  ,		snake_case_	:    Dict  ,		snake_case_	:    int=False ):
							UpperCamelCase_:							Any		=  copy.deepcopy(snake_case_ )

							if model_class == VideoMAEForPreTraining:
											# important: each video needs to have the same number of masked patches
											# hence we define a single mask, which we then repeat for each example in the batch
											UpperCamelCase_:							Dict		=  torch.ones((self.model_tester.num_masks,) )
											UpperCamelCase_:							Optional[Any]		=  torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0 ) )] )
											UpperCamelCase_:							Union[str, Any]		=  mask.expand(self.model_tester.batch_size  ,		-1 ).bool()
											UpperCamelCase_:							Any		=  bool_masked_pos.to(snake_case_ )

							if return_labels:
											if model_class in [
											    *get_values(snake_case_ ),
											]:
															UpperCamelCase_:							Dict		=  torch.zeros(
															    self.model_tester.batch_size  ,		dtype=torch.long  ,		device=snake_case_ )

							return inputs_dict

			def  lowerCAmelCase__		(    self	:    List[str] ):
							self.config_tester.run_common_tests()

			@unittest.skip(reason="""VideoMAE does not use inputs_embeds""" )
			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							pass

			def  lowerCAmelCase__		(    self	:    int ):
							UpperCamelCase_,				UpperCamelCase_:							str		=  self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											UpperCamelCase_:							Tuple		=  model_class(snake_case_ )
											self.assertIsInstance(model.get_input_embeddings()  ,		(nn.Module) )
											UpperCamelCase_:							Any		=  model.get_output_embeddings()
											self.assertTrue(x is None or isinstance(snake_case_  ,		nn.Linear ) )

			def  lowerCAmelCase__		(    self	:    Tuple ):
							UpperCamelCase_,				UpperCamelCase_:							Optional[Any]		=  self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											UpperCamelCase_:							Tuple		=  model_class(snake_case_ )
											UpperCamelCase_:							List[Any]		=  inspect.signature(model.forward )
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											UpperCamelCase_:							Any		=  [*signature.parameters.keys()]

											UpperCamelCase_:							Optional[Any]		=  ["""pixel_values"""]
											self.assertListEqual(arg_names[:1]  ,		snake_case_ )

			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							UpperCamelCase_:							Optional[Any]		=  self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*snake_case_ )

			def  lowerCAmelCase__		(    self	:    List[str] ):
							UpperCamelCase_:							Optional[int]		=  self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_pretraining(*snake_case_ )

			@slow
			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											UpperCamelCase_:							Union[str, Any]		=  VideoMAEModel.from_pretrained(snake_case_ )
											self.assertIsNotNone(snake_case_ )

			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							if not self.has_attentions:
											pass

							else:
											UpperCamelCase_,				UpperCamelCase_:							Any		=  self.model_tester.prepare_config_and_inputs_for_common()
											UpperCamelCase_:							int		=  True

											for model_class in self.all_model_classes:
															UpperCamelCase_:							Dict		=  self.model_tester.seq_length - self.model_tester.num_masks
															UpperCamelCase_:							Optional[int]		=  (
															    num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
															)

															UpperCamelCase_:							Optional[int]		=  True
															UpperCamelCase_:							List[Any]		=  False
															UpperCamelCase_:							Optional[int]		=  True
															UpperCamelCase_:							Optional[Any]		=  model_class(snake_case_ )
															model.to(snake_case_ )
															model.eval()
															with torch.no_grad():
																			UpperCamelCase_:							Any		=  model(**self._prepare_for_class(snake_case_  ,		snake_case_ ) )
															UpperCamelCase_:							Union[str, Any]		=  outputs.attentions
															self.assertEqual(len(snake_case_ )  ,		self.model_tester.num_hidden_layers )

															# check that output_attentions also work using config
															del inputs_dict["output_attentions"]
															UpperCamelCase_:							List[Any]		=  True
															UpperCamelCase_:							Optional[Any]		=  model_class(snake_case_ )
															model.to(snake_case_ )
															model.eval()
															with torch.no_grad():
																			UpperCamelCase_:							Union[str, Any]		=  model(**self._prepare_for_class(snake_case_  ,		snake_case_ ) )
															UpperCamelCase_:							Union[str, Any]		=  outputs.attentions
															self.assertEqual(len(snake_case_ )  ,		self.model_tester.num_hidden_layers )

															self.assertListEqual(
															    list(attentions[0].shape[-3:] )  ,		[self.model_tester.num_attention_heads, seq_len, seq_len]  ,		)
															UpperCamelCase_:							Dict		=  len(snake_case_ )

															# Check attention is always last and order is fine
															UpperCamelCase_:							Optional[int]		=  True
															UpperCamelCase_:							List[str]		=  True
															UpperCamelCase_:							Dict		=  model_class(snake_case_ )
															model.to(snake_case_ )
															model.eval()
															with torch.no_grad():
																			UpperCamelCase_:							List[Any]		=  model(**self._prepare_for_class(snake_case_  ,		snake_case_ ) )

															self.assertEqual(out_len + 1  ,		len(snake_case_ ) )

															UpperCamelCase_:							Optional[int]		=  outputs.attentions

															self.assertEqual(len(snake_case_ )  ,		self.model_tester.num_hidden_layers )
															self.assertListEqual(
															    list(self_attentions[0].shape[-3:] )  ,		[self.model_tester.num_attention_heads, seq_len, seq_len]  ,		)

			def  lowerCAmelCase__		(    self	:    Dict ):
							def check_hidden_states_output(snake_case_	:    str  ,		snake_case_	:    Tuple  ,		snake_case_	:    List[Any] ):
											UpperCamelCase_:							Any		=  model_class(snake_case_ )
											model.to(snake_case_ )
											model.eval()

											with torch.no_grad():
															UpperCamelCase_:							List[Any]		=  model(**self._prepare_for_class(snake_case_  ,		snake_case_ ) )

											UpperCamelCase_:							Optional[Any]		=  outputs.hidden_states
											UpperCamelCase_:							List[Any]		=  self.model_tester.num_hidden_layers + 1
											self.assertEqual(len(snake_case_ )  ,		snake_case_ )

											UpperCamelCase_:							List[Any]		=  self.model_tester.seq_length - self.model_tester.num_masks
											UpperCamelCase_:							Tuple		=  num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

											self.assertListEqual(
											    list(hidden_states[0].shape[-2:] )  ,		[seq_length, self.model_tester.hidden_size]  ,		)

							UpperCamelCase_,				UpperCamelCase_:							List[Any]		=  self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											UpperCamelCase_:							str		=  True
											check_hidden_states_output(snake_case_  ,		snake_case_  ,		snake_case_ )

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											UpperCamelCase_:							Tuple		=  True

											check_hidden_states_output(snake_case_  ,		snake_case_  ,		snake_case_ )




			@unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests.""" )
			def  lowerCAmelCase__		(    self	:    str ):
							pass







def     A__   (  )					->		Optional[Any]:
				UpperCamelCase_:							Union[str, Any]		=  hf_hub_download(
				    repo_id="""hf-internal-testing/spaghetti-video"""       ,      filename="""eating_spaghetti.npy"""       ,      repo_type="""dataset"""  )
				UpperCamelCase_:							Optional[Any]		=  np.load(lowerCamelCase  )
				return list(lowerCamelCase  )





@require_torch
@require_vision
class     _UpperCamelCase			(   unittest.TestCase					):






			'''simple docstring'''

			@cached_property
			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							# logits were tested with a different mean and std, so we use the same here
							return (
							    VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5]  ,		image_std=[0.5, 0.5, 0.5] )
							    if is_vision_available()
							    else None
							)

			@slow
			def  lowerCAmelCase__		(    self	:    List[Any] ):
							UpperCamelCase_:							Any		=  VideoMAEForVideoClassification.from_pretrained("""MCG-NJU/videomae-base-finetuned-kinetics""" ).to(
							    snake_case_ )

							UpperCamelCase_:							Union[str, Any]		=  self.default_image_processor
							UpperCamelCase_:							Dict		=  prepare_video()
							UpperCamelCase_:							str		=  image_processor(snake_case_  ,		return_tensors="""pt""" ).to(snake_case_ )

							# forward pass
							with torch.no_grad():
											UpperCamelCase_:							str		=  model(**snake_case_ )

							# verify the logits
							UpperCamelCase_:							Tuple		=  torch.Size((1, 400) )
							self.assertEqual(outputs.logits.shape  ,		snake_case_ )

							UpperCamelCase_:							Union[str, Any]		=  torch.tensor([0.3669, -0.0688, -0.2421] ).to(snake_case_ )

							self.assertTrue(torch.allclose(outputs.logits[0, :3]  ,		snake_case_  ,		atol=1e-4 ) )




			@slow
			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							UpperCamelCase_:							Dict		=  VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short""" ).to(snake_case_ )

							UpperCamelCase_:							int		=  self.default_image_processor
							UpperCamelCase_:							Union[str, Any]		=  prepare_video()
							UpperCamelCase_:							Tuple		=  image_processor(snake_case_  ,		return_tensors="""pt""" ).to(snake_case_ )

							# add boolean mask, indicating which patches to mask
							UpperCamelCase_:							str		=  hf_hub_download(repo_id="""hf-internal-testing/bool-masked-pos"""  ,		filename="""bool_masked_pos.pt""" )
							UpperCamelCase_:							List[str]		=  torch.load(snake_case_ )

							# forward pass
							with torch.no_grad():
											UpperCamelCase_:							str		=  model(**snake_case_ )

							# verify the logits
							UpperCamelCase_:							str		=  torch.Size([1, 1408, 1536] )
							UpperCamelCase_:							str		=  torch.tensor(
							    [[0.7994, 0.9612, 0.8508], [0.7401, 0.8958, 0.8302], [0.5862, 0.7468, 0.7325]]  ,		device=snake_case_ )
							self.assertEqual(outputs.logits.shape  ,		snake_case_ )
							self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]  ,		snake_case_  ,		atol=1e-4 ) )

							# verify the loss (`config.norm_pix_loss` = `True`)
							UpperCamelCase_:							str		=  torch.tensor([0.5142]  ,		device=snake_case_ )
							self.assertTrue(torch.allclose(outputs.loss  ,		snake_case_  ,		atol=1e-4 ) )

							# verify the loss (`config.norm_pix_loss` = `False`)
							UpperCamelCase_:							Any		=  VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""  ,		norm_pix_loss=snake_case_ ).to(
							    snake_case_ )

							with torch.no_grad():
											UpperCamelCase_:							Dict		=  model(**snake_case_ )

							UpperCamelCase_:							str		=  torch.tensor(torch.tensor([0.6469] )  ,		device=snake_case_ )
							self.assertTrue(torch.allclose(outputs.loss  ,		snake_case_  ,		atol=1e-4 ) )








from datasets.utils.patching import _PatchedModuleObj, patch_submodule

from . import _test_patching







def     A__   (  )					->		Union[str, Any]:
				import os as original_os
				from os import path as original_path
				from os import rename as original_rename
				from os.path import dirname as original_dirname
				from os.path import join as original_join

				assert _test_patching.os is original_os
				assert _test_patching.path is original_path
				assert _test_patching.join is original_join

				assert _test_patching.renamed_os is original_os
				assert _test_patching.renamed_path is original_path
				assert _test_patching.renamed_join is original_join

				UpperCamelCase_:							Optional[int]		=  """__test_patch_submodule_mock__"""
				with patch_submodule(_test_patching       ,      """os.path.join"""       ,      lowerCamelCase  ):
								# Every way to access os.path.join must be patched, and the rest must stay untouched

								# check os.path.join
								assert isinstance(_test_patching.os       ,      _PatchedModuleObj  )
								assert isinstance(_test_patching.os.path       ,      _PatchedModuleObj  )
								assert _test_patching.os.path.join is mock

								# check path.join
								assert isinstance(_test_patching.path       ,      _PatchedModuleObj  )
								assert _test_patching.path.join is mock

								# check join
								assert _test_patching.join is mock

								# check that the other attributes are untouched
								assert _test_patching.os.rename is original_rename
								assert _test_patching.path.dirname is original_dirname
								assert _test_patching.os.path.dirname is original_dirname

								# Even renamed modules or objects must be patched

								# check renamed_os.path.join
								assert isinstance(_test_patching.renamed_os       ,      _PatchedModuleObj  )
								assert isinstance(_test_patching.renamed_os.path       ,      _PatchedModuleObj  )
								assert _test_patching.renamed_os.path.join is mock

								# check renamed_path.join
								assert isinstance(_test_patching.renamed_path       ,      _PatchedModuleObj  )
								assert _test_patching.renamed_path.join is mock

								# check renamed_join
								assert _test_patching.renamed_join is mock

								# check that the other attributes are untouched
								assert _test_patching.renamed_os.rename is original_rename
								assert _test_patching.renamed_path.dirname is original_dirname
								assert _test_patching.renamed_os.path.dirname is original_dirname

				# check that everthing is back to normal when the patch is over

				assert _test_patching.os is original_os
				assert _test_patching.path is original_path
				assert _test_patching.join is original_join

				assert _test_patching.renamed_os is original_os
				assert _test_patching.renamed_path is original_path
				assert _test_patching.renamed_join is original_join







def     A__   (  )					->		Union[str, Any]:
				assert _test_patching.open is open

				UpperCamelCase_:							List[Any]		=  """__test_patch_submodule_builtin_mock__"""
				# _test_patching has "open" in its globals
				assert _test_patching.open is open
				with patch_submodule(_test_patching       ,      """open"""       ,      lowerCamelCase  ):
								assert _test_patching.open is mock

				# check that everthing is back to normal when the patch is over

				assert _test_patching.open is open







def     A__   (  )					->		Optional[Any]:
				# pandas.read_csv is not present in _test_patching
				UpperCamelCase_:							Optional[Any]		=  """__test_patch_submodule_missing_mock__"""
				with patch_submodule(_test_patching       ,      """pandas.read_csv"""       ,      lowerCamelCase  ):
								pass







def     A__   (  )					->		Any:
				# builtin should always be mocked even if they're not in the globals
				# in case they're loaded at one point
				UpperCamelCase_:							List[Any]		=  """__test_patch_submodule_missing_builtin_mock__"""
				# _test_patching doesn't have "len" in its globals
				assert getattr(_test_patching       ,      """len"""       ,      lowerCamelCase  ) is None
				with patch_submodule(_test_patching       ,      """len"""       ,      lowerCamelCase  ):
								assert _test_patching.len is mock
				assert _test_patching.len is len







def     A__   (  )					->		Any:
				UpperCamelCase_:							Dict		=  """__test_patch_submodule_start_and_stop_mock__"""
				UpperCamelCase_:							List[str]		=  patch_submodule(_test_patching       ,      """open"""       ,      lowerCamelCase  )
				assert _test_patching.open is open
				patch.start()
				assert _test_patching.open is mock
				patch.stop()
				assert _test_patching.open is open







def     A__   (  )					->		List[str]:
				from os import rename as original_rename
				from os.path import dirname as original_dirname
				from os.path import join as original_join

				UpperCamelCase_:							Optional[Any]		=  """__test_patch_submodule_successive_join__"""
				UpperCamelCase_:							Any		=  """__test_patch_submodule_successive_dirname__"""
				UpperCamelCase_:							Dict		=  """__test_patch_submodule_successive_rename__"""
				assert _test_patching.os.path.join is original_join
				assert _test_patching.os.path.dirname is original_dirname
				assert _test_patching.os.rename is original_rename

				with patch_submodule(_test_patching       ,      """os.path.join"""       ,      lowerCamelCase  ):
								with patch_submodule(_test_patching       ,      """os.rename"""       ,      lowerCamelCase  ):
												with patch_submodule(_test_patching       ,      """os.path.dirname"""       ,      lowerCamelCase  ):
																assert _test_patching.os.path.join is mock_join
																assert _test_patching.os.path.dirname is mock_dirname
																assert _test_patching.os.rename is mock_rename

    # try another order
				with patch_submodule(_test_patching       ,      """os.rename"""       ,      lowerCamelCase  ):
								with patch_submodule(_test_patching       ,      """os.path.join"""       ,      lowerCamelCase  ):
												with patch_submodule(_test_patching       ,      """os.path.dirname"""       ,      lowerCamelCase  ):
																assert _test_patching.os.path.join is mock_join
																assert _test_patching.os.path.dirname is mock_dirname
																assert _test_patching.os.rename is mock_rename

				assert _test_patching.os.path.join is original_join
				assert _test_patching.os.path.dirname is original_dirname
				assert _test_patching.os.rename is original_rename







def     A__   (  )					->		Union[str, Any]:
				UpperCamelCase_:							Dict		=  """__test_patch_submodule_doesnt_exist_mock__"""
				with patch_submodule(_test_patching       ,      """__module_that_doesn_exist__.__attribute_that_doesn_exist__"""       ,      lowerCamelCase  ):
								pass
				with patch_submodule(_test_patching       ,      """os.__attribute_that_doesn_exist__"""       ,      lowerCamelCase  ):
								pass






