def METHOD_NAME(cls, key_size=2048, options=None, is_private=False) -> 'RSAKey':
    if key_size < 512:
        raise ValueError('key_size must not be less than 512')
    if key_size % 8 != 0:
        raise ValueError('Invalid key_size for RSAKey')
    raw_key = rsa.generate_private_key(
        public_exponent=65537,
        key_size=key_size,
        backend=default_backend(),
    )
    if not is_private:
        raw_key = raw_key.public_key()
    return cls.import_key(raw_key, options=options)