<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_app_metadata(template_dict):
 """ Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundError """

    if SERVERLESS_REPO_APPLICATION in template_dict.get(METADATA, {}):
        app_metadata_dict = template_dict.get(METADATA).get(SERVERLESS_REPO_APPLICATION)
        return ApplicationMetadata(app_metadata_dict)

    raise ApplicationMetadataNotFoundError(
        error_message='missing {} section in template Metadata'.format(SERVERLESS_REPO_APPLICATION))