




'''simple docstring'''





import warnings
from typing import List

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import is_flax_available, is_tf_available, is_torch_available

class        _a    (						_a							):
					SCREAMING_SNAKE_CASE_							:   Optional[Any]       =						["""image_processor""", """tokenizer"""]
					SCREAMING_SNAKE_CASE_							:   Optional[Any]       =						"""OwlViTImageProcessor"""
					SCREAMING_SNAKE_CASE_							:   Any       =						("""CLIPTokenizer""", """CLIPTokenizerFast""")






					def __init__(			self ,_SCREAMING_SNAKE_CASE=None ,_SCREAMING_SNAKE_CASE=None ,**_SCREAMING_SNAKE_CASE   )							->      Dict:
										_snake_case							=				None
										if "feature_extractor" in kwargs:
															warnings.warn(
															    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
															    " instead." ,__lowerCamelCase ,)
															_snake_case							=				kwargs.pop("feature_extractor"   )

										_snake_case							=				image_processor if image_processor is not None else feature_extractor
										if image_processor is None:
															raise ValueError("You need to specify an `image_processor`."   )
										if tokenizer is None:
															raise ValueError("You need to specify a `tokenizer`."   )

										super().__init__(__lowerCamelCase ,__lowerCamelCase   )






					def __call__(			self ,_SCREAMING_SNAKE_CASE=None ,_SCREAMING_SNAKE_CASE=None ,_SCREAMING_SNAKE_CASE=None ,_SCREAMING_SNAKE_CASE="max_length" ,_SCREAMING_SNAKE_CASE="np" ,**_SCREAMING_SNAKE_CASE   )							->      Optional[Any]:

										if text is None and query_images is None and images is None:
															raise ValueError(
															    "You have to specify at least one text or query image or image. All three cannot be none."   )

										if text is not None:
															if isinstance(__lowerCamelCase ,__lowerCamelCase   ) or (isinstance(__lowerCamelCase ,__lowerCamelCase   ) and not isinstance(text[0] ,__lowerCamelCase   )):
																				_snake_case							=				[self.tokenizer(__lowerCamelCase ,padding=__lowerCamelCase ,return_tensors=__lowerCamelCase ,**__lowerCamelCase   )]

															elif isinstance(__lowerCamelCase ,__lowerCamelCase   ) and isinstance(text[0] ,__lowerCamelCase   ):
																				_snake_case							=				[]

																				# Maximum number of queries across batch
																				_snake_case							=				max([len(__lowerCamelCase   ) for t in text]   )

																				# Pad all batch samples to max number of text queries
																				for t in text:
																									if len(__lowerCamelCase   ) != max_num_queries:
																														_snake_case							=				t + [""" """] * (max_num_queries - len(__lowerCamelCase   ))

																									_snake_case							=				self.tokenizer(__lowerCamelCase ,padding=__lowerCamelCase ,return_tensors=__lowerCamelCase ,**__lowerCamelCase   )
																									encodings.append(__lowerCamelCase   )
															else:
																				raise TypeError("Input text should be a string, a list of strings or a nested list of strings"   )

															if return_tensors == "np":
																				_snake_case							=				np.concatenate([encoding["input_ids"] for encoding in encodings] ,axis=0   )
																				_snake_case							=				np.concatenate([encoding["attention_mask"] for encoding in encodings] ,axis=0   )

															elif return_tensors == "jax" and is_flax_available():
																				import jax.numpy as jnp

																				_snake_case							=				jnp.concatenate([encoding["input_ids"] for encoding in encodings] ,axis=0   )
																				_snake_case							=				jnp.concatenate([encoding["attention_mask"] for encoding in encodings] ,axis=0   )

															elif return_tensors == "pt" and is_torch_available():
																				import torch

																				_snake_case							=				torch.cat([encoding["input_ids"] for encoding in encodings] ,dim=0   )
																				_snake_case							=				torch.cat([encoding["attention_mask"] for encoding in encodings] ,dim=0   )

															elif return_tensors == "tf" and is_tf_available():
																				import tensorflow as tf

																				_snake_case							=				tf.stack([encoding["input_ids"] for encoding in encodings] ,axis=0   )
																				_snake_case							=				tf.stack([encoding["attention_mask"] for encoding in encodings] ,axis=0   )

															else:
																				raise ValueError("Target return tensor type could not be returned"   )

															_snake_case							=				BatchEncoding()
															_snake_case							=				input_ids
															_snake_case							=				attention_mask

										if query_images is not None:
															_snake_case							=				BatchEncoding()
															_snake_case							=				self.image_processor(
															    __lowerCamelCase ,return_tensors=__lowerCamelCase ,**__lowerCamelCase   ).pixel_values
															_snake_case							=				query_pixel_values

										if images is not None:
															_snake_case							=				self.image_processor(__lowerCamelCase ,return_tensors=__lowerCamelCase ,**__lowerCamelCase   )

										if text is not None and images is not None:
															_snake_case							=				image_features.pixel_values
															return encoding
										elif query_images is not None and images is not None:
															_snake_case							=				image_features.pixel_values
															return encoding
										elif text is not None or query_images is not None:
															return encoding
										else:
															return BatchEncoding(data=dict(**__lowerCamelCase   ) ,tensor_type=__lowerCamelCase   )






					def     _lowercase     (			self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE   )							->      Union[str, Any]:
										return self.image_processor.post_process(*__lowerCamelCase ,**__lowerCamelCase   )






					def     _lowercase     (			self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE   )							->      List[str]:
										return self.image_processor.post_process_object_detection(*__lowerCamelCase ,**__lowerCamelCase   )






					def     _lowercase     (			self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE   )							->      Union[str, Any]:
										return self.image_processor.post_process_image_guided_detection(*__lowerCamelCase ,**__lowerCamelCase   )






					def     _lowercase     (			self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE   )							->      Optional[Any]:
										return self.tokenizer.batch_decode(*__lowerCamelCase ,**__lowerCamelCase   )






					def     _lowercase     (			self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE   )							->      Any:
										return self.tokenizer.decode(*__lowerCamelCase ,**__lowerCamelCase   )






					@property
					def     _lowercase     (			self   )							->      Any:
										warnings.warn(
										    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead." ,__lowerCamelCase ,)
										return self.image_processor_class






					@property
					def     _lowercase     (			self   )							->      Optional[int]:
										warnings.warn(
										    "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead." ,__lowerCamelCase ,)
										return self.image_processor








'''simple docstring'''





from decimal import Decimal, getcontext
from math import ceil, factorial





def      __a     (       _UpperCamelCase:   int   )						->			str:

     """simple docstring"""




     if not isinstance(_UpperCamelCase ,						_UpperCamelCase   ):
          raise TypeError("Undefined for non-integers"   )
     elif precision < 1:
          raise ValueError("Undefined for non-natural numbers"   )

     _snake_case							=				precision
     _snake_case							=				ceil(precision / 14   )
     _snake_case							=				426_880 * Decimal(10_005   ).sqrt()
     _snake_case							=				1
     _snake_case							=				13_591_409
     _snake_case							=				Decimal(_UpperCamelCase   )
     for k in range(1 ,						_UpperCamelCase   ):
          _snake_case							=				factorial(6 * k   ) // (factorial(3 * k   ) * factorial(_UpperCamelCase   ) ** 3)
          linear_term += 545_140_134
          exponential_term *= -262_537_412_640_768_000
          partial_sum += Decimal(multinomial_term * linear_term   ) / exponential_term
     return str(constant_term / partial_sum   )[:-1]


if __name__ == "__main__":
   UpperCamelCase_						:      Any       =						50
   print(F'The first {n} digits of pi is: {pi(n)}')


