






"""simple docstring"""



import subprocess
import sys

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

class        a     (   lowerCAmelCase_	):







    @require_torch
    def 			UpperCamelCase_      (			self       ):
      # 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
      lowercase							    =       '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

      lowercase							    =       '\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        '

      lowercase							    =       '\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
      lowercase							    =       '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
      lowercase							    =       [sys.executable, '-c', '\n'.join([load, run, mock]       )]

      # should succeed
      lowercase							    =       self.get_env()
      # should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
      lowercase							    =       '1'
      lowercase							    =       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 			UpperCamelCase_      (			self       ):
      # python one-liner segments
      # this must be loaded before socket.socket is monkey-patched
      lowercase							    =       '\nfrom transformers import BertConfig, BertModel, BertTokenizer, pipeline\n        '

      lowercase							    =       '\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        '

      lowercase							    =       '\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
      lowercase							    =       '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
      lowercase							    =       [sys.executable, '-c', '\n'.join([load, run, mock]       )]

      # should succeed
      lowercase							    =       self.get_env()
      lowercase							    =       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 			UpperCamelCase_      (			self       ):
      # 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
      lowercase							    =       '\nfrom transformers import BertConfig, BertModel, BertTokenizer\n        '

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

      lowercase							    =       '\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
      lowercase							    =       [sys.executable, '-c', '\n'.join([load, run]       )]

      # should succeed
      lowercase							    =       self.get_env()
      lowercase							    =       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
      lowercase							    =       [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
      lowercase							    =       '1'
      lowercase							    =       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 			UpperCamelCase_      (			self       ):
      lowercase							    =       '\nfrom transformers import pipeline\n        '
      lowercase							    =       '\nmname = \"hf-internal-testing/tiny-random-bert\"\npipe = pipeline(model=mname)\n        '

      lowercase							    =       '\nimport socket\ndef offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")\nsocket.socket = offline_socket\n        '
      lowercase							    =       self.get_env()
      lowercase							    =       '1'
      lowercase							    =       [sys.executable, '-c', '\n'.join([load, mock, run]       )]
      lowercase							    =       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 			UpperCamelCase_      (			self       ):
      lowercase							    =       '\nfrom transformers import AutoModel\n        '
      lowercase							    =       '\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
      lowercase							    =       [sys.executable, '-c', '\n'.join([load, run]       )]

      # should succeed
      lowercase							    =       self.get_env()
      lowercase							    =       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
      lowercase							    =       '1'
      lowercase							    =       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()       )









'''simple docstring'''




def 	UpperCAmelCase_							(					__lowercase							:      str       )		->       list:


     '''simple docstring'''



     if n_term == "":
          return []
     _UpperCAmelCase     							=   []
     for temp in range(int(__lowercase       )       ):
          series.append(f'1/{temp + 1}' if series else "1"       )
     return series


if __name__ == "__main__":
  __SCREAMING_SNAKE_CASE     :str       =				input('''Enter the last number (nth term) of the Harmonic Series''')
  print('''Formula of Harmonic Series => 1+1/2+1/3 ..... 1/n''')
  print(harmonic_series(nth_term))




