






"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


SCREAMING_SNAKE_CASE_					:	Any							  =						{
    'configuration_jukebox': [
        'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'JukeboxConfig',
        'JukeboxPriorConfig',
        'JukeboxVQVAEConfig',
    ],
    'tokenization_jukebox': ['JukeboxTokenizer'],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE_					:	Union[str, Any]							  =						[
     'JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST',
     'JukeboxModel',
     'JukeboxPreTrainedModel',
     'JukeboxVQVAE',
     'JukeboxPrior',
 ]

if TYPE_CHECKING:
 from .configuration_jukebox import (
     JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP,
     JukeboxConfig,
     JukeboxPriorConfig,
     JukeboxVQVAEConfig,
 )
 from .tokenization_jukebox import JukeboxTokenizer

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_jukebox import (
      JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST,
      JukeboxModel,
      JukeboxPreTrainedModel,
      JukeboxPrior,
      JukeboxVQVAE,
  )

else:
 import sys

 SCREAMING_SNAKE_CASE_					:	Optional[int]							  =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)









"""simple docstring"""



from collections.abc import Callable





def  _snake_case     (    UpperCAmelCase_  :					Callable[[float], float]					,   UpperCAmelCase_  :					float					,   UpperCAmelCase_  :					float			):
     A__										=  a
     A__										=  b
     if function(UpperCAmelCase_			) == 0:  # one of the a or b is a root for the function
          return a
     elif function(UpperCAmelCase_			) == 0:
          return b
     elif (
         function(UpperCAmelCase_			) * function(UpperCAmelCase_			) > 0
     ):  # if none of these are root and they are both positive or negative,
          # then this algorithm can't find the root
          raise ValueError("""could not find root in given interval."""			)
     else:
          A__										=  start + (end - start) / 2.0
          while abs(start - mid			) > 10**-7:  # until precisely equals to 10^-7
               if function(UpperCAmelCase_			) == 0:
                    return mid
               elif function(UpperCAmelCase_			) * function(UpperCAmelCase_			) < 0:
                    A__										=  mid
               else:
                    A__										=  mid
               A__										=  start + (end - start) / 2.0
          return mid





def  _snake_case     (    UpperCAmelCase_  :					float			):
     return x**3 - 2 * x - 5


if __name__ == "__main__":
 print(bisection(f, 1, 1_0_0_0))

 import doctest

 doctest.testmod()






