<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_reference(images, reference):
 """ Ensure the reference matches image dimensions """

    if not images.shape[1:] == reference.shape:
        raise Exception('Image shape %s and reference shape %s must match'
                        % (images.shape[1:], reference.shape))
    return reference