


"""simple docstring"""







import unittest

import requests

from transformers import MODEL_FOR_VISION_2_SEQ_MAPPING, TF_MODEL_FOR_VISION_2_SEQ_MAPPING, is_vision_available
from transformers.pipelines import pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    is_torch_available,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_torch_available():
						from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
						__a			 =   False


if is_vision_available():
						from PIL import Image
else:
						class 							lowerCamelCase       :


													"""simple docstring"""






													@staticmethod
													def 					lowerCAmelCase     (						*lowerCamelCase_ :     Union[str, Any]		, **lowerCamelCase_ :     Optional[int]				):
																			pass
@is_pipeline_test
@require_vision
class 							lowerCamelCase       (			unittest.TestCase ):


							"""simple docstring"""
							SCREAMING_SNAKE_CASE										=      MODEL_FOR_VISION_2_SEQ_MAPPING
							SCREAMING_SNAKE_CASE										=      TF_MODEL_FOR_VISION_2_SEQ_MAPPING






							def 					lowerCAmelCase     (						self :     List[Any]		, lowerCamelCase_ :     Tuple		, lowerCamelCase_ :     List[Any]		, lowerCamelCase_ :     str				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model=lowerCamelCase_		, tokenizer=lowerCamelCase_		, image_processor=lowerCamelCase_				)
													UpperCAmelCase__		=    [
													    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''				),
													    '''./tests/fixtures/tests_samples/COCO/000000039769.png''',
													]
													return pipe, examples






							def 					lowerCAmelCase     (						self :     Tuple		, lowerCamelCase_ :     Dict		, lowerCamelCase_ :     int				):
													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        [{'''generated_text''': ANY(lowerCamelCase_				)}],
													        [{'''generated_text''': ANY(lowerCamelCase_				)}],
													    ]		, )






							@require_tf
							def 					lowerCAmelCase     (						self :     Optional[int]				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''hf-internal-testing/tiny-random-vit-gpt2'''		, framework='''tf'''				)
													UpperCAmelCase__		=    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        {
													            '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													        },
													    ]		, )

													UpperCAmelCase__		=    pipe([image, image]				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        [
													            {
													                '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													            }
													        ],
													        [
													            {
													                '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													            }
													        ],
													    ]		, )

													UpperCAmelCase__		=    pipe(lowerCamelCase_		, max_new_tokens=1				)
													self.assertEqual(
													    lowerCamelCase_		, [{'''generated_text''': '''growth'''}]		, )






							@require_torch
							def 					lowerCAmelCase     (						self :     str				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''hf-internal-testing/tiny-random-vit-gpt2'''				)
													UpperCAmelCase__		=    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        {
													            '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													        },
													    ]		, )

													UpperCAmelCase__		=    pipe([image, image]				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        [
													            {
													                '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													            }
													        ],
													        [
													            {
													                '''generated_text''': '''growthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthgrowthGOGO'''
													            }
													        ],
													    ]		, )






							@require_torch
							def 					lowerCAmelCase     (						self :     Optional[int]				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''hf-internal-testing/tiny-random-BlipForConditionalGeneration'''				)
													UpperCAmelCase__		=    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''
													UpperCAmelCase__		=    '''a photo of'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_		, prompt=lowerCamelCase_				)
													self.assertTrue(outputs[0]['''generated_text'''].startswith(lowerCamelCase_				)				)






							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     Tuple				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''ydshieh/vit-gpt2-coco-en'''				)
													UpperCAmelCase__		=    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}]				)

													UpperCAmelCase__		=    pipe([image, image]				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}],
													        [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}],
													    ]		, )






							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     Any				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''Salesforce/blip-image-captioning-base'''				)
													UpperCAmelCase__		=    '''https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png'''
													UpperCAmelCase__		=    Image.open(requests.get(lowerCamelCase_		, stream=lowerCamelCase_				).raw				)

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a pink pokemon pokemon with a blue shirt and a blue shirt'''}]				)






							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     int				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''microsoft/git-base-coco'''				)
													UpperCAmelCase__		=    '''https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png'''
													UpperCAmelCase__		=    Image.open(requests.get(lowerCamelCase_		, stream=lowerCamelCase_				).raw				)

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a cartoon of a purple character.'''}]				)






							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     Optional[int]				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''Salesforce/blip-image-captioning-base'''				)
													UpperCAmelCase__		=    '''https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg'''
													UpperCAmelCase__		=    Image.open(requests.get(lowerCamelCase_		, stream=lowerCamelCase_				).raw				)

													UpperCAmelCase__		=    '''a photography of'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_		, prompt=lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a photography of a volcano'''}]				)

													with self.assertRaises(lowerCamelCase_				):
																			UpperCAmelCase__		=    pipe([image, image]		, prompt=[prompt, prompt]				)






							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     Union[str, Any]				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''microsoft/git-base-coco'''				)
													UpperCAmelCase__		=    '''https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg'''
													UpperCAmelCase__		=    Image.open(requests.get(lowerCamelCase_		, stream=lowerCamelCase_				).raw				)

													UpperCAmelCase__		=    '''a photo of a'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_		, prompt=lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a photo of a tent with a tent and a tent in the background.'''}]				)

													with self.assertRaises(lowerCamelCase_				):
																			UpperCAmelCase__		=    pipe([image, image]		, prompt=[prompt, prompt]				)






							@unittest.skipIf(
							    not is_torch_greater_or_equal_than_1_11		, reason='''`Pix2StructImageProcessor` requires `torch>=1.11.0`.'''				)
							@slow
							@require_torch
							def 					lowerCAmelCase     (						self :     Any				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''google/pix2struct-ai2d-base'''				)
													UpperCAmelCase__		=    '''https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/ai2d-demo.jpg'''
													UpperCAmelCase__		=    Image.open(requests.get(lowerCamelCase_		, stream=lowerCamelCase_				).raw				)

													UpperCAmelCase__		=    '''What does the label 15 represent? (1) lava (2) core (3) tunnel (4) ash cloud'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_		, prompt=lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''ash cloud'''}]				)

													with self.assertRaises(lowerCamelCase_				):
																			UpperCAmelCase__		=    pipe([image, image]		, prompt=[prompt, prompt]				)






							@slow
							@require_tf
							def 					lowerCAmelCase     (						self :     Optional[int]				):
													UpperCAmelCase__		=    pipeline('''image-to-text'''		, model='''ydshieh/vit-gpt2-coco-en'''		, framework='''tf'''				)
													UpperCAmelCase__		=    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''

													UpperCAmelCase__		=    pipe(lowerCamelCase_				)
													self.assertEqual(lowerCamelCase_		, [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}]				)

													UpperCAmelCase__		=    pipe([image, image]				)
													self.assertEqual(
													    lowerCamelCase_		, [
													        [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}],
													        [{'''generated_text''': '''a cat laying on a blanket next to a cat laying on a bed '''}],
													    ]		, )



"""simple docstring"""







from collections import defaultdict






def 					a__ (       _UpperCamelCase = 5 ):





						"""simple docstring"""

						UpperCAmelCase__		=    defaultdict(_UpperCamelCase )
						UpperCAmelCase__		=    0

						while True:
												UpperCAmelCase__		=    get_digits(_UpperCamelCase )
												freqs[digits].append(_UpperCamelCase )

												if len(freqs[digits] ) == max_base:
																		UpperCAmelCase__		=    freqs[digits][0] ** 3
																		return base

												num += 1






def 					a__ (       _UpperCamelCase ):





						"""simple docstring"""

						return "".join(sorted(str(num**3 ) ) )


if __name__ == "__main__":
						print(f'''{solution() = }''')