<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def share_application_with_accounts(application_id, account_ids, sar_client=None):
 """ Share the application privately with given AWS account IDs. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param account_ids: List of AWS account IDs, or * :type account_ids: list of str :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client :raises ValueError """

    if not application_id or not account_ids:
        raise ValueError('Require application id and list of AWS account IDs to share the app')

    if not sar_client:
        sar_client = boto3.client('serverlessrepo')

    application_policy = ApplicationPolicy(account_ids, [ApplicationPolicy.DEPLOY])
    application_policy.validate()
    sar_client.put_application_policy(
        ApplicationId=application_id,
        Statements=[application_policy.to_statement()]
    )