


import os
import sys
import unittest


snake_case							:       List[Any]     			=      os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, '''utils'''))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
snake_case							:       str     			=      os.path.join(git_repo_path, '''src''', '''diffusers''')







class        snake_case_   (unittest.TestCase      ):
					def  lowerCamelCase__(      self   :Union[str, Any]      )					->    str:
												a__             =     find_backend('    if not is_torch_available():'      )
												self.assertEqual(__snake_case			,'torch'      )

												# backend_with_underscore = find_backend("    if not is_tensorflow_text_available():")
												# self.assertEqual(backend_with_underscore, "tensorflow_text")

												a__             =     find_backend('    if not (is_torch_available() and is_transformers_available()):'      )
												self.assertEqual(__snake_case			,'torch_and_transformers'      )

												# double_backend_with_underscore = find_backend(
												#    "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"
												# )
												# self.assertEqual(double_backend_with_underscore, "sentencepiece_and_tensorflow_text")

												a__             =     find_backend(
												    '    if not (is_torch_available() and is_transformers_available() and is_onnx_available()):'      )
												self.assertEqual(__snake_case			,'torch_and_transformers_and_onnx'      )
					def  lowerCamelCase__(      self   :Union[str, Any]      )					->    Tuple:
												a__             =     read_init()
												# We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
												self.assertIn('torch'			,__snake_case      )
												self.assertIn('torch_and_transformers'			,__snake_case      )
												self.assertIn('flax_and_transformers'			,__snake_case      )
												self.assertIn('torch_and_transformers_and_onnx'			,__snake_case      )

												# Likewise, we can't assert on the exact content of a key
												self.assertIn('UNet2DModel'			,objects['torch']      )
												self.assertIn('FlaxUNet2DConditionModel'			,objects['flax']      )
												self.assertIn('StableDiffusionPipeline'			,objects['torch_and_transformers']      )
												self.assertIn('FlaxStableDiffusionPipeline'			,objects['flax_and_transformers']      )
												self.assertIn('LMSDiscreteScheduler'			,objects['torch_and_scipy']      )
												self.assertIn('OnnxStableDiffusionPipeline'			,objects['torch_and_transformers_and_onnx']      )
					def  lowerCamelCase__(      self   :Any      )					->    Dict:
												a__             =     create_dummy_object('CONSTANT'			,'\'torch\''      )
												self.assertEqual(__snake_case			,'\nCONSTANT = None\n'      )

												a__             =     create_dummy_object('function'			,'\'torch\''      )
												self.assertEqual(
												    __snake_case			,'\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'      )

												a__             =     '\nclass FakeClass(metaclass=DummyObject):\n    _backends = \'torch\'\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, \'torch\')\n\n    @classmethod\n    def from_config(cls, *args, **kwargs):\n        requires_backends(cls, \'torch\')\n\n    @classmethod\n    def from_pretrained(cls, *args, **kwargs):\n        requires_backends(cls, \'torch\')\n'
												a__             =     create_dummy_object('FakeClass'			,'\'torch\''      )
												self.assertEqual(__snake_case			,__snake_case      )



					def  lowerCamelCase__(      self   :Optional[int]      )					->    Optional[Any]:
												a__             =     '# This file is autogenerated by the command `make fix-copies`, do not edit.\nfrom ..utils import DummyObject, requires_backends\n\n\nCONSTANT = None\n\n\ndef function(*args, **kwargs):\n    requires_backends(function, ["torch"])\n\n\nclass FakeClass(metaclass=DummyObject):\n    _backends = ["torch"]\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, ["torch"])\n\n    @classmethod\n    def from_config(cls, *args, **kwargs):\n        requires_backends(cls, ["torch"])\n\n    @classmethod\n    def from_pretrained(cls, *args, **kwargs):\n        requires_backends(cls, ["torch"])\n'
												a__             =     create_dummy_files({'torch': ['CONSTANT', 'function', 'FakeClass']}      )
												self.assertEqual(dummy_files['torch']			,__snake_case      )








import math






def 							__lowercase   ( __lowerCAmelCase							:				int   ):
							a__             =     [True] * n
							a__             =     False
							a__             =     False
							a__             =     True

							for i in range(3					,    int(n**0.5 + 1   )					,    2   ):
														a__             =     i * 2
														while index < n:
																					a__             =     False
																					a__             =     index + i

							a__             =     [2]

							for i in range(3					,    __lowerCAmelCase					,    2   ):
														if is_prime[i]:
																					primes.append(__lowerCAmelCase   )

							return primes






def 							__lowercase   ( __lowerCAmelCase							:				int = 9_9_9_9_6_6_6_6_3_3_3_3   ):
							a__             =     math.floor(math.sqrt(__lowerCAmelCase   )   ) + 1_0_0
							a__             =     prime_sieve(__lowerCAmelCase   )

							a__             =     0
							a__             =     0
							a__             =     primes[prime_index]

							while (last_prime**2) <= limit:
														a__             =     primes[prime_index + 1]

														a__             =     last_prime**2
														a__             =     next_prime**2

														# Get numbers divisible by lps(current)
														a__             =     lower_bound + last_prime
														while upper_bound > current <= limit:
																					matches_sum += current
																					current += last_prime

														# Reset the upper_bound
														while (upper_bound - next_prime) > limit:
																					upper_bound -= next_prime

														# Add the numbers divisible by ups(current)
														a__             =     upper_bound - next_prime
														while current > lower_bound:
																					matches_sum += current
																					current -= next_prime

														# Remove the numbers divisible by both ups and lps
														a__             =     0
														while upper_bound > current <= limit:
																					if current <= lower_bound:
																												# Increment the current number
																												current += last_prime * next_prime
																												continue

																					if current > limit:
																												break

																					# Remove twice since it was added by both ups and lps
																					matches_sum -= current * 2

																					# Increment the current number
																					current += last_prime * next_prime

														# Setup for next pair
														a__             =     next_prime
														prime_index += 1

							return matches_sum


if __name__ == "__main__":
						print(solution())




