





'''simple docstring'''







snake_case_     :       List[str]									=  range(2, 20 + 1)
snake_case_     :       Optional[Any]									=  [10**k for k in range(ks[-1] + 1)]
snake_case_     :       dict[int, dict[int, list[list[int]]]]									=  {}





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			Any,			SCREAMING_SNAKE_CASE__      :			Dict,			SCREAMING_SNAKE_CASE__      :			Any,			SCREAMING_SNAKE_CASE__      :			Optional[Any]   ) ->	int:
						UpperCAmelCase_			:      Tuple     						=  sum(a_i[j] for j in range(__UpperCamelCase,			len(__UpperCamelCase   )   )   )
						UpperCAmelCase_			:      Tuple     						=  sum(a_i[j] * base[j] for j in range(min(len(__UpperCamelCase   ),			__UpperCamelCase   )   )   )

						UpperCAmelCase_			:      Optional[int]     						=  0, 0
						UpperCAmelCase_			:      List[Any]     						=  n - i

						UpperCAmelCase_			:      Any     						=  memo.get(__UpperCamelCase   )

						if sub_memo is not None:
												UpperCAmelCase_			:      Optional[int]     						=  sub_memo.get(__UpperCamelCase   )

												if jumps is not None and len(__UpperCamelCase   ) > 0:
																		# find and make the largest jump without going over
																		UpperCAmelCase_			:      List[Any]     						=  -1
																		for _k in range(len(__UpperCamelCase   ) - 1,			-1,			-1   ):
																								if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
																														UpperCAmelCase_			:      List[str]     						=  _k
																														break

																		if max_jump >= 0:
																								UpperCAmelCase_			:      List[Any]     						=  jumps[max_jump]
																								# since the difference between jumps is cached, add c
																								UpperCAmelCase_			:      int     						=  diff + c
																								for j in range(min(__UpperCamelCase,			len(__UpperCamelCase   )   )   ):
																														UpperCAmelCase_			:      List[str]     						=  divmod(__UpperCamelCase,			10   )
																								if new_c > 0:
																														add(__UpperCamelCase,			__UpperCamelCase,			__UpperCamelCase   )

												else:
																		UpperCAmelCase_			:      List[Any]     						=  []
						else:
												UpperCAmelCase_			:      Optional[Any]     						=  {c: []}
												UpperCAmelCase_			:      int     						=  sub_memo

						if dn >= max_dn or c + diff >= base[k]:
												return diff, dn

						if k > ks[0]:
												while True:
																		# keep doing smaller jumps
																		UpperCAmelCase_			:      str     						=  next_term(__UpperCamelCase,			k - 1,			i + dn,			__UpperCamelCase   )
																		diff += _diff
																		dn += terms_jumped

																		if dn >= max_dn or c + diff >= base[k]:
																								break
						else:
												# would be too small a jump, just compute sequential terms instead
												UpperCAmelCase_			:      str     						=  compute(__UpperCamelCase,			__UpperCamelCase,			i + dn,			__UpperCamelCase   )
												diff += _diff
												dn += terms_jumped

						UpperCAmelCase_			:      str     						=  sub_memo[c]

						# keep jumps sorted by # of terms skipped
						UpperCAmelCase_			:      List[Any]     						=  0
						while j < len(__UpperCamelCase   ):
												if jumps[j][1] > dn:
																		break
												j += 1

						# cache the jump for this value digitsum(b) and c
						sub_memo[c].insert(__UpperCamelCase,			(diff, dn, k)   )
						return (diff, dn)





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int,			SCREAMING_SNAKE_CASE__      :			Optional[int],			SCREAMING_SNAKE_CASE__      :			List[str],			SCREAMING_SNAKE_CASE__      :			int   ) ->	Any:







						if i >= n:
												return 0, i
						if k > len(__UpperCamelCase   ):
												a_i.extend([0 for _ in range(k - len(__UpperCamelCase   )   )]   )

						# note: a_i -> b * 10^k + c
						# ds_b -> digitsum(b)
						# ds_c -> digitsum(c)
						UpperCAmelCase_			:      Optional[Any]     						=  i
						UpperCAmelCase_			:      Dict     						=  0, 0, 0
						for j in range(len(__UpperCamelCase   )   ):
												if j >= k:
																		ds_b += a_i[j]
												else:
																		ds_c += a_i[j]

						while i < n:
												i += 1
												UpperCAmelCase_			:      int     						=  ds_c + ds_b
												diff += addend
												UpperCAmelCase_			:      List[Any]     						=  0
												for j in range(__UpperCamelCase   ):
																		UpperCAmelCase_			:      Optional[Any]     						=  a_i[j] + addend
																		UpperCAmelCase_			:      List[str]     						=  divmod(__UpperCamelCase,			10   )

																		ds_c += a_i[j]

												if addend > 0:
																		break

						if addend > 0:
												add(__UpperCamelCase,			__UpperCamelCase,			__UpperCamelCase   )
						return diff, i - start_i





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			Dict,			SCREAMING_SNAKE_CASE__      :			List[Any],			SCREAMING_SNAKE_CASE__      :			int   ) ->	Tuple:







						for j in range(__UpperCamelCase,			len(__UpperCamelCase   )   ):
												UpperCAmelCase_			:      Any     						=  digits[j] + addend
												if s >= 10:
																		UpperCAmelCase_			:      Union[str, Any]     						=  divmod(__UpperCamelCase,			10   )
																		UpperCAmelCase_			:      Optional[int]     						=  addend // 10 + quotient
												else:
																		UpperCAmelCase_			:      Any     						=  s
																		UpperCAmelCase_			:      Dict     						=  addend // 10

												if addend == 0:
																		break

						while addend > 0:
												UpperCAmelCase_			:      Dict     						=  divmod(__UpperCamelCase,			10   )
												digits.append(__UpperCamelCase   )





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int = 10**15   ) ->	int:
						UpperCAmelCase_			:      List[Any]     						=  [1]
						UpperCAmelCase_			:      Dict     						=  1
						UpperCAmelCase_			:      Tuple     						=  0
						while True:
												UpperCAmelCase_			:      List[str]     						=  next_term(__UpperCamelCase,			20,			i + dn,			__UpperCamelCase   )
												dn += terms_jumped
												if dn == n - i:
																		break

						UpperCAmelCase_			:      List[str]     						=  0
						for j in range(len(__UpperCamelCase   )   ):
												a_n += digits[j] * 10**j
						return a_n


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












'''simple docstring'''







# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

import torch

from ..models.auto import AutoModelForVisualQuestionAnswering, AutoProcessor
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
					from PIL import Image


class 					__a      (lowerCamelCase     ):
							__a					:   int									=       "dandelin/vilt-b32-finetuned-vqa"
							__a					:   Any									=       (
							    "This is a tool that answers a question about an image. It takes an input named `image` which should be the "
							    "image containing the information, as well as a `question` which should be the question in English. It "
							    "returns a text that is the answer to the question."
							)
							__a					:   Any									=       "image_qa"
							__a					:   str									=       AutoProcessor
							__a					:   Any									=       AutoModelForVisualQuestionAnswering

							__a					:   List[Any]									=       ["image", "text"]
							__a					:   int									=       ["text"]

							def __init__(							self							:     Tuple       ,     *__magic_name__							:     Any       ,     **__magic_name__							:     Any   )					->       Tuple:







													"""simple docstring"""
													requires_backends(self       ,     ['''vision''']   )
													super().__init__(*__magic_name__       ,     **__magic_name__   )

							def     UpperCAmelCase__	(							self							:     Union[str, Any]       ,     __magic_name__							:     "Image"       ,     __magic_name__							:     str   )					->       Tuple:







													"""simple docstring"""
													return self.pre_processor(__magic_name__       ,     __magic_name__       ,     return_tensors='''pt'''   )

							def     UpperCAmelCase__	(							self							:     Any       ,     __magic_name__							:     List[str]   )					->       Optional[Any]:







													"""simple docstring"""
													with torch.no_grad():
																			return self.model(**__magic_name__   ).logits



							def     UpperCAmelCase__	(							self							:     int       ,     __magic_name__							:     int   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  outputs.argmax(-1   ).item()
													return self.model.config.idalabel[idx]





