

'''simple docstring'''


import inspect
import unittest

from transformers import SegformerConfig, is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

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 transformers import (
					    MODEL_MAPPING,
					    SegformerForImageClassification,
					    SegformerForSemanticSegmentation,
					    SegformerModel,
					)
					from transformers.models.segformer.modeling_segformer import SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from PIL import Image

					from transformers import SegformerImageProcessor




class      a      (					SCREAMING_SNAKE_CASE_							):






						"""simple docstring"""




						def    __magic_name__				(				self       :   int	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	self.config_class(**self.inputs_dict	)
								self.parent.assertTrue(hasattr(snake_case_      ,      '''hidden_sizes'''	)	)
								self.parent.assertTrue(hasattr(snake_case_      ,      '''num_attention_heads'''	)	)
								self.parent.assertTrue(hasattr(snake_case_      ,      '''num_encoder_blocks'''	)	)





class      a      :






						"""simple docstring"""




						def __init__(				self       :   List[str]      ,      snake_case_       :   Union[str, Any]      ,      snake_case_       :   int=1_3      ,      snake_case_       :   List[str]=6_4      ,      snake_case_       :   int=3      ,      snake_case_       :   Union[str, Any]=4      ,      snake_case_       :   Optional[Any]=[2, 2, 2, 2]      ,      snake_case_       :   Dict=[8, 4, 2, 1]      ,      snake_case_       :   str=[1_6, 3_2, 6_4, 1_2_8]      ,      snake_case_       :   int=[1, 4, 8, 1_6]      ,      snake_case_       :   Optional[int]=[1, 2, 4, 8]      ,      snake_case_       :   str=True      ,      snake_case_       :   Optional[int]=True      ,      snake_case_       :   List[Any]="gelu"      ,      snake_case_       :   Any=0.1      ,      snake_case_       :   List[Any]=0.1      ,      snake_case_       :   Tuple=0.0_2      ,      snake_case_       :   Tuple=3      ,      snake_case_       :   Optional[int]=None      ,      ):



								'''simple docstring'''



								snake_case__    :							str							    =	parent
								snake_case__    :							List[str]							    =	batch_size
								snake_case__    :							Tuple							    =	image_size
								snake_case__    :							Optional[Any]							    =	num_channels
								snake_case__    :							Optional[Any]							    =	num_encoder_blocks
								snake_case__    :							List[str]							    =	sr_ratios
								snake_case__    :							Dict							    =	depths
								snake_case__    :							Dict							    =	hidden_sizes
								snake_case__    :							Optional[Any]							    =	downsampling_rates
								snake_case__    :							str							    =	num_attention_heads
								snake_case__    :							Dict							    =	is_training
								snake_case__    :							Optional[Any]							    =	use_labels
								snake_case__    :							str							    =	hidden_act
								snake_case__    :							Dict							    =	hidden_dropout_prob
								snake_case__    :							Any							    =	attention_probs_dropout_prob
								snake_case__    :							Any							    =	initializer_range
								snake_case__    :							Union[str, Any]							    =	num_labels
								snake_case__    :							int							    =	scope







						def    __magic_name__				(				self       :   List[Any]	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]	)

								snake_case__    :							Union[str, Any]							    =	None
								if self.use_labels:
										snake_case__    :							List[Any]							    =	ids_tensor([self.batch_size, self.image_size, self.image_size]      ,      self.num_labels	)

								snake_case__    :							Any							    =	self.get_config()
								return config, pixel_values, labels







						def    __magic_name__				(				self       :   Any	):



								'''simple docstring'''



								return SegformerConfig(
								    image_size=self.image_size      ,      num_channels=self.num_channels      ,      num_encoder_blocks=self.num_encoder_blocks      ,      depths=self.depths      ,      hidden_sizes=self.hidden_sizes      ,      num_attention_heads=self.num_attention_heads      ,      hidden_act=self.hidden_act      ,      hidden_dropout_prob=self.hidden_dropout_prob      ,      attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,      initializer_range=self.initializer_range      ,      )







						def    __magic_name__				(				self       :   Tuple      ,      snake_case_       :   Optional[int]      ,      snake_case_       :   Tuple      ,      snake_case_       :   Optional[int]	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	SegformerModel(config=snake_case_	)
								model.to(snake_case_	)
								model.eval()
								snake_case__    :							Union[str, Any]							    =	model(snake_case_	)
								snake_case__    :							List[Any]							    =	self.image_size // (self.downsampling_rates[-1] * 2)
								self.parent.assertEqual(
								    result.last_hidden_state.shape      ,      (self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)	)







						def    __magic_name__				(				self       :   Union[str, Any]      ,      snake_case_       :   Any      ,      snake_case_       :   List[Any]      ,      snake_case_       :   str	):



								'''simple docstring'''



								snake_case__    :							str							    =	self.num_labels
								snake_case__    :							Optional[Any]							    =	SegformerForSemanticSegmentation(snake_case_	)
								model.to(snake_case_	)
								model.eval()
								snake_case__    :							Optional[Any]							    =	model(snake_case_	)
								self.parent.assertEqual(
								    result.logits.shape      ,      (self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)	)
								snake_case__    :							Dict							    =	model(snake_case_      ,      labels=snake_case_	)
								self.parent.assertEqual(
								    result.logits.shape      ,      (self.batch_size, self.num_labels, self.image_size // 4, self.image_size // 4)	)
								self.parent.assertGreater(result.loss      ,      0.0	)







						def    __magic_name__				(				self       :   Any      ,      snake_case_       :   Optional[Any]      ,      snake_case_       :   int      ,      snake_case_       :   List[str]	):



								'''simple docstring'''



								snake_case__    :							List[Any]							    =	1
								snake_case__    :							str							    =	SegformerForSemanticSegmentation(config=snake_case_	)
								model.to(snake_case_	)
								model.eval()
								snake_case__    :							Dict							    =	torch.randint(0      ,      1      ,      (self.batch_size, self.image_size, self.image_size)	).to(snake_case_	)
								snake_case__    :							Tuple							    =	model(snake_case_      ,      labels=snake_case_	)
								self.parent.assertGreater(result.loss      ,      0.0	)







						def    __magic_name__				(				self       :   Optional[Any]	):



								'''simple docstring'''



								snake_case__    :							str							    =	self.prepare_config_and_inputs()
								snake_case__    :							Tuple							    =	config_and_inputs
								snake_case__    :							List[str]							    =	{'pixel_values': pixel_values}
								return config, inputs_dict





@require_torch
class      a      (					SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      unittest.TestCase							):






						"""simple docstring"""




						__UpperCAmelCase        =     (
						    (
						        SegformerModel,
						        SegformerForSemanticSegmentation,
						        SegformerForImageClassification,
						    )
						    if is_torch_available()
						    else ()
						)
						__UpperCAmelCase        =     (
						    {
						        """feature-extraction""": SegformerModel,
						        """image-classification""": SegformerForImageClassification,
						        """image-segmentation""": SegformerForSemanticSegmentation,
						    }
						    if is_torch_available()
						    else {}
						)

						__UpperCAmelCase        =     True
						__UpperCAmelCase        =     False
						__UpperCAmelCase        =     False
						__UpperCAmelCase        =     False







						def    __magic_name__				(				self       :   str	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	SegformerModelTester(self	)
								snake_case__    :							int							    =	SegformerConfigTester(self      ,      config_class=snake_case_	)







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								self.config_tester.run_common_tests()







						def    __magic_name__				(				self       :   List[Any]	):



								'''simple docstring'''



								snake_case__    :							Any							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*snake_case_	)







						def    __magic_name__				(				self       :   Optional[int]	):



								'''simple docstring'''



								snake_case__    :							Optional[Any]							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_binary_image_segmentation(*snake_case_	)







						def    __magic_name__				(				self       :   Union[str, Any]	):



								'''simple docstring'''



								snake_case__    :							int							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_segmentation(*snake_case_	)







						@unittest.skip('''SegFormer does not use inputs_embeds'''	)
						def    __magic_name__				(				self       :   Union[str, Any]	):



								'''simple docstring'''



								pass







						@unittest.skip('''SegFormer does not have get_input_embeddings method and get_output_embeddings methods'''	)
						def    __magic_name__				(				self       :   Optional[Any]	):



								'''simple docstring'''



								pass







						def    __magic_name__				(				self       :   str	):



								'''simple docstring'''



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

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

										snake_case__    :							List[Any]							    =	['pixel_values']
										self.assertListEqual(arg_names[:1]      ,      snake_case_	)







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								snake_case__    :							List[Any]							    =	self.model_tester.prepare_config_and_inputs_for_common()
								snake_case__    :							Optional[int]							    =	True

								for model_class in self.all_model_classes:
										snake_case__    :							str							    =	True
										snake_case__    :							Optional[Any]							    =	False
										snake_case__    :							Dict							    =	True
										snake_case__    :							int							    =	model_class(snake_case_	)
										model.to(snake_case_	)
										model.eval()
										with torch.no_grad():
												snake_case__    :							Union[str, Any]							    =	model(**self._prepare_for_class(snake_case_      ,      snake_case_	)	)
										snake_case__    :							List[str]							    =	outputs.attentions

										snake_case__    :							Tuple							    =	sum(self.model_tester.depths	)
										self.assertEqual(len(snake_case_	)      ,      snake_case_	)

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

										self.assertEqual(len(snake_case_	)      ,      snake_case_	)

										# verify the first attentions (first block, first layer)
										snake_case__    :							Tuple							    =	(self.model_tester.image_size // 4) ** 2
										snake_case__    :							str							    =	(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
										self.assertListEqual(
										    list(attentions[0].shape[-3:]	)      ,      [self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]      ,      )

										# verify the last attentions (last block, last layer)
										snake_case__    :							List[Any]							    =	(self.model_tester.image_size // 3_2) ** 2
										snake_case__    :							List[Any]							    =	(self.model_tester.image_size // (3_2 * self.model_tester.sr_ratios[-1])) ** 2
										self.assertListEqual(
										    list(attentions[-1].shape[-3:]	)      ,      [self.model_tester.num_attention_heads[-1], expected_seq_len, expected_reduced_seq_len]      ,      )
										snake_case__    :							Optional[Any]							    =	len(snake_case_	)

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

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

										snake_case__    :							Dict							    =	outputs.attentions

										self.assertEqual(len(snake_case_	)      ,      snake_case_	)
										# verify the first attentions (first block, first layer)
										snake_case__    :							Dict							    =	(self.model_tester.image_size // 4) ** 2
										snake_case__    :							Any							    =	(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
										self.assertListEqual(
										    list(self_attentions[0].shape[-3:]	)      ,      [self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]      ,      )







						def    __magic_name__				(				self       :   Optional[int]	):



								'''simple docstring'''



								def check_hidden_states_output(snake_case_       :   Any      ,      snake_case_       :   int      ,      snake_case_       :   str	):
										snake_case__    :							Union[str, Any]							    =	model_class(snake_case_	)
										model.to(snake_case_	)
										model.eval()

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

										snake_case__    :							Union[str, Any]							    =	outputs.hidden_states

										snake_case__    :							int							    =	self.model_tester.num_encoder_blocks
										self.assertEqual(len(snake_case_	)      ,      snake_case_	)

										# verify the first hidden states (first block)
										self.assertListEqual(
										    list(hidden_states[0].shape[-3:]	)      ,      [
										        self.model_tester.hidden_sizes[0],
										        self.model_tester.image_size // 4,
										        self.model_tester.image_size // 4,
										    ]      ,      )

								snake_case__    :							Optional[Any]							    =	self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
										snake_case__    :							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"]
										snake_case__    :							List[Any]							    =	True

										check_hidden_states_output(snake_case_      ,      snake_case_      ,      snake_case_	)







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								if not self.model_tester.is_training:
										return

								snake_case__    :							Tuple							    =	self.model_tester.prepare_config_and_inputs_for_common()
								snake_case__    :							int							    =	True

								for model_class in self.all_model_classes:
										if model_class in get_values(snake_case_	):
												continue

										snake_case__    :							str							    =	model_class(snake_case_	)
										model.to(snake_case_	)
										model.train()
										snake_case__    :							str							    =	self._prepare_for_class(snake_case_      ,      snake_case_      ,      return_labels=snake_case_	)
										snake_case__    :							Tuple							    =	model(**snake_case_	).loss
										loss.backward()







						@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''	)
						def    __magic_name__				(				self       :   Union[str, Any]	):



								'''simple docstring'''



								pass







						@slow
						def    __magic_name__				(				self       :   str	):



								'''simple docstring'''



								for model_name in SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										snake_case__    :							Optional[int]							    =	SegformerModel.from_pretrained(snake_case_	)
										self.assertIsNotNone(snake_case_	)





def 						_a							(					):

		"""simple docstring"""

		snake_case__    :							Tuple							    =	Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''  )
		return image





@require_torch
class      a      (					unittest.TestCase							):






						"""simple docstring"""




						@slow
						def    __magic_name__				(				self       :   Any	):



								'''simple docstring'''



								snake_case__    :							List[Any]							    =	SegformerImageProcessor(
								    image_scale=(5_1_2, 5_1_2)      ,      keep_ratio=snake_case_      ,      align=snake_case_      ,      do_random_crop=snake_case_	)
								snake_case__    :							Dict							    =	SegformerForSemanticSegmentation.from_pretrained('''nvidia/segformer-b0-finetuned-ade-512-512'''	).to(
								    snake_case_	)

								snake_case__    :							Any							    =	prepare_img()
								snake_case__    :							Optional[Any]							    =	image_processor(images=snake_case_      ,      return_tensors='''pt'''	)
								snake_case__    :							Union[str, Any]							    =	encoded_inputs.pixel_values.to(snake_case_	)

								with torch.no_grad():
										snake_case__    :							str							    =	model(snake_case_	)

								snake_case__    :							Tuple							    =	torch.Size((1, model.config.num_labels, 1_2_8, 1_2_8)	)
								self.assertEqual(outputs.logits.shape      ,      snake_case_	)

								snake_case__    :							Union[str, Any]							    =	torch.tensor(
								    [
								        [[-4.6_3_1_0, -5.5_2_3_2, -6.2_3_5_6], [-5.1_9_2_1, -6.1_4_4_4, -6.5_9_9_6], [-5.4_4_2_4, -6.2_7_9_0, -6.7_5_7_4]],
								        [[-1_2.1_3_9_1, -1_3.3_1_2_2, -1_3.9_5_5_4], [-1_2.8_7_3_2, -1_3.9_3_5_2, -1_4.3_5_6_3], [-1_2.9_4_3_8, -1_3.8_2_2_6, -1_4.2_5_1_3]],
								        [[-1_2.5_1_3_4, -1_3.4_6_8_6, -1_4.4_9_1_5], [-1_2.8_6_6_9, -1_4.4_3_4_3, -1_4.7_7_5_8], [-1_3.2_5_2_3, -1_4.5_8_1_9, -1_5.0_6_9_4]],
								    ]	).to(snake_case_	)
								self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3]      ,      snake_case_      ,      atol=1e-4	)	)







						@slow
						def    __magic_name__				(				self       :   Any	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	SegformerImageProcessor(
								    image_scale=(5_1_2, 5_1_2)      ,      keep_ratio=snake_case_      ,      align=snake_case_      ,      do_random_crop=snake_case_	)
								snake_case__    :							Dict							    =	SegformerForSemanticSegmentation.from_pretrained(
								    '''nvidia/segformer-b1-finetuned-cityscapes-1024-1024'''	).to(snake_case_	)

								snake_case__    :							int							    =	prepare_img()
								snake_case__    :							str							    =	image_processor(images=snake_case_      ,      return_tensors='''pt'''	)
								snake_case__    :							Optional[Any]							    =	encoded_inputs.pixel_values.to(snake_case_	)

								with torch.no_grad():
										snake_case__    :							Dict							    =	model(snake_case_	)

								snake_case__    :							List[str]							    =	torch.Size((1, model.config.num_labels, 1_2_8, 1_2_8)	)
								self.assertEqual(outputs.logits.shape      ,      snake_case_	)

								snake_case__    :							Tuple							    =	torch.tensor(
								    [
								        [[-1_3.5_7_4_8, -1_3.9_1_1_1, -1_2.6_5_0_0], [-1_4.3_5_0_0, -1_5.3_6_8_3, -1_4.2_3_2_8], [-1_4.7_5_3_2, -1_6.0_4_2_4, -1_5.6_0_8_7]],
								        [[-1_7.1_6_5_1, -1_5.8_7_2_5, -1_2.9_6_5_3], [-1_7.2_5_8_0, -1_7.3_7_1_8, -1_4.8_2_2_3], [-1_6.6_0_5_8, -1_6.8_7_8_3, -1_6.7_4_5_2]],
								        [[-3.6_4_5_6, -3.0_2_0_9, -1.4_2_0_3], [-3.0_7_9_7, -3.1_9_5_9, -2.0_0_0_0], [-1.8_7_5_7, -1.9_2_1_7, -1.6_9_9_7]],
								    ]	).to(snake_case_	)
								self.assertTrue(torch.allclose(outputs.logits[0, :3, :3, :3]      ,      snake_case_      ,      atol=1e-1	)	)







						@slow
						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	SegformerImageProcessor(
								    image_scale=(5_1_2, 5_1_2)      ,      keep_ratio=snake_case_      ,      align=snake_case_      ,      do_random_crop=snake_case_	)
								snake_case__    :							str							    =	SegformerForSemanticSegmentation.from_pretrained('''nvidia/segformer-b0-finetuned-ade-512-512'''	).to(
								    snake_case_	)

								snake_case__    :							Dict							    =	prepare_img()
								snake_case__    :							int							    =	image_processor(images=snake_case_      ,      return_tensors='''pt'''	)
								snake_case__    :							List[Any]							    =	encoded_inputs.pixel_values.to(snake_case_	)

								with torch.no_grad():
										snake_case__    :							Optional[Any]							    =	model(snake_case_	)

								snake_case__    :							Optional[Any]							    =	outputs.logits.detach().cpu()

								snake_case__    :							Any							    =	image_processor.post_process_semantic_segmentation(outputs=snake_case_      ,      target_sizes=[(5_0_0, 3_0_0)]	)
								snake_case__    :							Optional[Any]							    =	torch.Size((5_0_0, 3_0_0)	)
								self.assertEqual(segmentation[0].shape      ,      snake_case_	)

								snake_case__    :							Dict							    =	image_processor.post_process_semantic_segmentation(outputs=snake_case_	)
								snake_case__    :							Optional[int]							    =	torch.Size((1_2_8, 1_2_8)	)
								self.assertEqual(segmentation[0].shape      ,      snake_case_	)








"""simple docstring"""







# Lint as: python3
import itertools
import os
import re


a_							=    re.compile(r"""([A-Z]+)([A-Z][a-z])""")
a_							=    re.compile(r"""([a-z\d])([A-Z])""")

a_							=    re.compile(r"""(?<!_)_(?!_)""")
a_							=    re.compile(r"""(_{2,})""")

a_							=    r"""^\w+(\.\w+)*$"""

a_							=    r"""<>:/\|?*"""

def     UpperCAmelCase_					(				__a   :			Optional[int]						):




			'''simple docstring'''



			_lowerCamelCase					:					str	       =    _uppercase_uppercase_re.sub(r'\1_\2'      ,							__a						)
			_lowerCamelCase					:					Tuple	       =    _lowercase_uppercase_re.sub(r'\1_\2'      ,							__a						)
			return name.lower()

def     UpperCAmelCase_					(				__a   :			Optional[int]						):




			'''simple docstring'''



			_lowerCamelCase					:					Dict	       =    _single_underscore_re.split(__a						)
			_lowerCamelCase					:					Tuple	       =    [_multiple_underscores_re.split(__a						) for n in name]
			return "".join(n.capitalize() for n in itertools.chain.from_iterable(__a						) if n != ''						)

def     UpperCAmelCase_					(				__a   :			List[Any]						):




			'''simple docstring'''



			if os.path.basename(__a						) != name:
						raise ValueError(f"Should be a dataset name, not a path: {name}"						)
			return camelcase_to_snakecase(__a						)

def     UpperCAmelCase_					(				__a   :			Union[str, Any]      ,							__a   :			Optional[int]						):




			'''simple docstring'''



			if os.path.basename(__a						) != name:
						raise ValueError(f"Should be a dataset name, not a path: {name}"						)
			if not re.match(_split_re      ,							__a						):
						raise ValueError(f"Split name should match '{_split_re}'' but got '{split}'."						)
			return f"{filename_prefix_for_name(__a						)}-{split}"

def     UpperCAmelCase_					(				__a   :			Any      ,							__a   :			Union[str, Any]      ,							__a   :			List[Any]      ,							__a   :			List[str]=None						):




			'''simple docstring'''



			_lowerCamelCase					:					List[Any]	       =    filename_prefix_for_split(__a      ,							__a						)
			if filetype_suffix:
						prefix += f".{filetype_suffix}"
			_lowerCamelCase					:					List[str]	       =    os.path.join(__a      ,							__a						)
			return f"{filepath}*"



def     UpperCAmelCase_					(				__a   :			str      ,							__a   :			List[Any]      ,							__a   :			List[str]      ,							__a   :			Tuple=None      ,							__a   :			Tuple=None						):




			'''simple docstring'''



			_lowerCamelCase					:					Tuple	       =    filename_prefix_for_split(__a      ,							__a						)
			_lowerCamelCase					:					List[str]	       =    os.path.join(__a      ,							__a						)

			if shard_lengths:
						_lowerCamelCase					:					Union[str, Any]	       =    len(__a						)
						_lowerCamelCase					:					str	       =    [f"{prefix}-{shard_id:05d}-of-{num_shards:05d}" for shard_id in range(__a						)]
						if filetype_suffix:
									_lowerCamelCase					:					int	       =    [filename + f".{filetype_suffix}" for filename in filenames]
						return filenames
			else:
						_lowerCamelCase					:					int	       =    prefix
						if filetype_suffix:
									filename += f".{filetype_suffix}"
						return [filename]





