


'''simple docstring'''

from collections import UserDict
from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
	from PIL import Image

	from ..image_utils import load_image

if is_torch_available():
	from ..models.auto.modeling_auto import MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING

if is_tf_available():
	from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING
	from ..tf_utils import stable_softmax

_UpperCAmelCase				: Any							    =				logging.get_logger(__name__)


@add_end_docstrings(__A      )
class       a__				( __A      ):







				"""simple docstring"""



				def __init__(self       ,			**__lowercase		):
										super().__init__(**__lowercase		)

										requires_backends(self       ,			'''vision'''		)
										self.check_model_type(
										    TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING
										    if self.framework == '''tf'''
										    else MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING		)




				def __call__(self       ,			__lowercase       ,			**__lowercase		):
										return super().__call__(__lowercase       ,			**__lowercase		)




				def 					_snake_case  (self       ,			**__lowercase		):
										__lowerCAmelCase							       =				{}
										if "candidate_labels" in kwargs:
																__lowerCAmelCase							       =				kwargs['''candidate_labels''']
										if "hypothesis_template" in kwargs:
																__lowerCAmelCase							       =				kwargs['''hypothesis_template''']

										return preprocess_params, {}, {}




				def 					_snake_case  (self       ,			__lowercase       ,			__lowercase=None       ,			__lowercase="This is a photo of {}."		):
										__lowerCAmelCase							       =				load_image(__lowercase		)
										__lowerCAmelCase							       =				self.image_processor(images=[image]       ,			return_tensors=self.framework		)
										__lowerCAmelCase							       =				candidate_labels
										__lowerCAmelCase							       =				[hypothesis_template.format(__lowercase		) for x in candidate_labels]
										__lowerCAmelCase							       =				self.tokenizer(__lowercase       ,			return_tensors=self.framework       ,			padding=__lowercase		)
										__lowerCAmelCase							       =				[text_inputs]
										return inputs




				def 					_snake_case  (self       ,			__lowercase		):
										__lowerCAmelCase							       =				model_inputs.pop('''candidate_labels'''		)
										__lowerCAmelCase							       =				model_inputs.pop('''text_inputs'''		)
										if isinstance(text_inputs[0]       ,			__lowercase		):
																__lowerCAmelCase							       =				text_inputs[0]
										else:
																# Batching case.
																__lowerCAmelCase							       =				text_inputs[0][0]

										__lowerCAmelCase							       =				self.model(**__lowercase       ,			**__lowercase		)

										__lowerCAmelCase							       =				{
										    '''candidate_labels''': candidate_labels,
										    '''logits''': outputs.logits_per_image,
										}
										return model_outputs




				def 					_snake_case  (self       ,			__lowercase		):
										__lowerCAmelCase							       =				model_outputs.pop('''candidate_labels'''		)
										__lowerCAmelCase							       =				model_outputs['''logits'''][0]
										if self.framework == "pt":
																__lowerCAmelCase							       =				logits.softmax(dim=-1		).squeeze(-1		)
																__lowerCAmelCase							       =				probs.tolist()
																if not isinstance(__lowercase       ,			__lowercase		):
																						__lowerCAmelCase							       =				[scores]
										elif self.framework == "tf":
																__lowerCAmelCase							       =				stable_softmax(__lowercase       ,			axis=-1		)
																__lowerCAmelCase							       =				probs.numpy().tolist()
										else:
																raise ValueError(F"""Unsupported framework: {self.framework}"""		)

										__lowerCAmelCase							       =				[
										    {'''score''': score, '''label''': candidate_label}
										    for score, candidate_label in sorted(zip(__lowercase       ,			__lowercase		)       ,			key=lambda __lowercase		: -x[0]		)
										]
										return result





'''simple docstring'''

from __future__ import annotations

def 							__magic_name__(						lowerCamelCase,				lowerCamelCase):
						__lowerCAmelCase							       =				sorted(numsa + numsa)
						__lowerCAmelCase       ,					__lowerCAmelCase							       =				divmod(len(lowerCamelCase),				2)
						if mod == 1:
												return all_numbers[div]
						else:
												return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	_UpperCAmelCase				: Union[str, Any]							    =				[float(x) for x in input("""Enter the elements of first array: """).split()]
	_UpperCAmelCase				: int							    =				[float(x) for x in input("""Enter the elements of second array: """).split()]
	print(f"""The median of two arrays is: {median_of_two_arrays(array_a, array_a)}""")

