


import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch







class  snake_case_     (lowerCamelCase_   ):
					@require_torch
					def 				lowerCamelCase__(   self     :Union[str, Any]   )      ->					List[Any]:
												# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
												# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
												# while running an external program

												# python one-liner segments

												# this must be loaded before socket.socket is monkey-patched
												a__    =  '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

												a__    =  '\nmname = "hf-internal-testing/tiny-random-bert"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task="fill-mask", model=mname)\nprint("success")\n        '

												a__    =  '\nimport socket\ndef offline_socket(*args, **kwargs): raise RuntimeError("Offline mode is enabled, we shouldn\'t access internet")\nsocket.socket = offline_socket\n        '

												# Force fetching the files so that we can use the cache
												a__    =  'hf-internal-testing/tiny-random-bert'
												BertConfig.from_pretrained(__snake_case   )
												BertModel.from_pretrained(__snake_case   )
												BertTokenizer.from_pretrained(__snake_case   )
												pipeline(task='fill-mask'    ,model=__snake_case   )

												# baseline - just load from_pretrained with normal network
												a__    =  [sys.executable, '-c', '\n'.join([load, run, mock]   )]

												# should succeed
												a__    =  self.get_env()
												# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
												a__    =  '1'
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )
					@require_torch
					def 				lowerCamelCase__(   self     :Dict   )      ->					List[Any]:
												# python one-liner segments
												# this must be loaded before socket.socket is monkey-patched
												a__    =  '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

												a__    =  '\nmname = "hf-internal-testing/tiny-random-bert"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nBertTokenizer.from_pretrained(mname)\npipe = pipeline(task="fill-mask", model=mname)\nprint("success")\n        '

												a__    =  '\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error("Faking flaky internet")\nsocket.socket = offline_socket\n        '

												# Force fetching the files so that we can use the cache
												a__    =  'hf-internal-testing/tiny-random-bert'
												BertConfig.from_pretrained(__snake_case   )
												BertModel.from_pretrained(__snake_case   )
												BertTokenizer.from_pretrained(__snake_case   )
												pipeline(task='fill-mask'    ,model=__snake_case   )

												# baseline - just load from_pretrained with normal network
												a__    =  [sys.executable, '-c', '\n'.join([load, run, mock]   )]

												# should succeed
												a__    =  self.get_env()
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )
					@require_torch
					def 				lowerCamelCase__(   self     :Dict   )      ->					Any:
												# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
												# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
												# while running an external program

												# python one-liner segments

												# this must be loaded before socket.socket is monkey-patched
												a__    =  '\nfrom transformers import BertConfig, BertModel, BertTokenizer\n        '

												a__    =  '\nmname = "hf-internal-testing/tiny-random-bert-sharded"\nBertConfig.from_pretrained(mname)\nBertModel.from_pretrained(mname)\nprint("success")\n        '

												a__    =  '\nimport socket\ndef offline_socket(*args, **kwargs): raise ValueError("Offline mode is enabled")\nsocket.socket = offline_socket\n        '

												# baseline - just load from_pretrained with normal network
												a__    =  [sys.executable, '-c', '\n'.join([load, run]   )]

												# should succeed
												a__    =  self.get_env()
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )

												# next emulate no network
												a__    =  [sys.executable, '-c', '\n'.join([load, mock, run]   )]

												# Doesn't fail anymore since the model is in the cache due to other tests, so commenting this.
												# env["TRANSFORMERS_OFFLINE"] = "0"
												# result = subprocess.run(cmd, env=env, check=False, capture_output=True)
												# self.assertEqual(result.returncode, 1, result.stderr)

												# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
												a__    =  '1'
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )
					@require_torch
					def 				lowerCamelCase__(   self     :str   )      ->					int:
												a__    =  '\nfrom transformers import pipeline\n        '
												a__    =  '\nmname = "hf-internal-testing/tiny-random-bert"\npipe = pipeline(model=mname)\n        '

												a__    =  '\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error("Offline mode is enabled")\nsocket.socket = offline_socket\n        '
												a__    =  self.get_env()
												a__    =  '1'
												a__    =  [sys.executable, '-c', '\n'.join([load, mock, run]   )]
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,1    ,result.stderr   )
												self.assertIn(
												    'You cannot infer task automatically within `pipeline` when using offline mode'    ,result.stderr.decode().replace('\n'    ,''   )    ,)



					@require_torch
					def 				lowerCamelCase__(   self     :List[str]   )      ->					Any:
												a__    =  '\nfrom transformers import AutoModel\n        '
												a__    =  '\nmname = "hf-internal-testing/test_dynamic_model"\nAutoModel.from_pretrained(mname, trust_remote_code=True)\nprint("success")\n        '

												# baseline - just load from_pretrained with normal network
												a__    =  [sys.executable, '-c', '\n'.join([load, run]   )]

												# should succeed
												a__    =  self.get_env()
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )

												# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
												a__    =  '1'
												a__    =  subprocess.run(__snake_case    ,env=__snake_case    ,check=__snake_case    ,capture_output=__snake_case   )
												self.assertEqual(result.returncode    ,0    ,result.stderr   )
												self.assertIn('success'    ,result.stdout.decode()   )








from math import ceil, sqrt






def 							__lowercase     (				__lowerCAmelCase							:       int = 1_0_0_0_0_0_0     ):
							a__    =  0

							for outer_width in range(3      ,					(limit // 4) + 2     ):
														if outer_width**2 > limit:
																					a__    =  max(ceil(sqrt(outer_width**2 - limit     )     )      ,					1     )
														else:
																					a__    =  1
														if (outer_width - hole_width_lower_bound) % 2:
																					hole_width_lower_bound += 1

														answer += (outer_width - hole_width_lower_bound - 2) // 2 + 1

							return answer


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




