




# 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

from ..models.auto import AutoModelForVisionaSeq
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
     from PIL import Image

class     __a(	_a  ):






    """simple docstring"""





    lowerCAmelCase         = '''Salesforce/blip-image-captioning-base'''
    lowerCAmelCase         = (
        '''This is a tool that generates a description of an image. It takes an input named `image` which should be the '''
        '''image to caption, and returns a text that contains the description in English.'''
    )
    lowerCAmelCase         = '''image_captioner'''
    lowerCAmelCase         = AutoModelForVisionaSeq

    lowerCAmelCase         = ['''image''']
    lowerCAmelCase         = ['''text''']





    def __init__( self  ,*_SCREAMING_SNAKE_CASE  ,**_SCREAMING_SNAKE_CASE    )					->						str:
         requires_backends(self  ,['''vision''']    )
         super().__init__(*_SCREAMING_SNAKE_CASE  ,**_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE    )					->						str:
         return self.pre_processor(images=_SCREAMING_SNAKE_CASE  ,return_tensors='''pt'''    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE    )					->						Any:
         return self.model.generate(**_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE    )					->						Union[str, Any]:
         return self.pre_processor.batch_decode(_SCREAMING_SNAKE_CASE  ,skip_special_tokens=_SCREAMING_SNAKE_CASE    )[0].strip()





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







def lowerCamelCase__  (     _lowercase ):

     '''simple docstring'''


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

     UpperCAmelCase_     :				Tuple  =     precision
     UpperCAmelCase_     :				Optional[Any]  =     ceil(precision / 14 )
     UpperCAmelCase_     :				int  =     426880 * Decimal(10005 ).sqrt()
     UpperCAmelCase_     :				Tuple  =     1
     UpperCAmelCase_     :				List[Any]  =     13591409
     UpperCAmelCase_     :				Optional[Any]  =     Decimal(_lowercase )
     for k in range(1					,		_lowercase ):
          UpperCAmelCase_     :				List[str]  =     factorial(6 * k ) // (factorial(3 * k ) * factorial(_lowercase ) ** 3)
          linear_term += 545140134
          exponential_term *= -262537412640768000
          partial_sum += Decimal(multinomial_term * linear_term ) / exponential_term
     return str(constant_term / partial_sum )[:-1]


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