input: Write a function to develop a Python script that generates an RSA public and private key pair. The function should create the keys, write the public key to a file named 'public.pem', and write the private key to a file named 'private.pem'. The function should execute upon being called.
  assert generate_key_pair()
  # The assertion checks if the function runs without errors, which implies the keys are correctly generated and saved.
output: def generate_key_pair():
      from cryptography.hazmat.primitives.asymmetric import rsa
      from cryptography.hazmat.primitives import serialization
  
      private_key = rsa.generate_private_key(
          public_exponent=65537,
          key_size=2048
      )
      public_key = private_key.public_key()
  
      pem_private = private_key.private_bytes(
          encoding=serialization.Encoding.PEM,
          format=serialization.PrivateFormat.PKCS8,
          encryption_algorithm=serialization.NoEncryption()
      )
      pem_public = public_key.public_bytes(
          encoding=serialization.Encoding.PEM,
          format=serialization.PublicFormat.SubjectPublicKeyInfo
      )
  
      with open('private.pem', 'wb') as f:
          f.write(pem_private)
      with open('public.pem', 'wb') as f:
          f.write(pem_public)