<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _compute_layer_version(is_defined_within_template, arn):
 """ Parses out the Layer version from the arn Parameters is_defined_within_template bool True if the resource is a Ref to a resource otherwise False arn str ARN of the Resource Returns ------- int The Version of the LayerVersion """


        if is_defined_within_template:
            return None

        try:
            _, layer_version = arn.rsplit(':', 1)
            layer_version = int(layer_version)
        except ValueError:
            raise InvalidLayerVersionArn(arn + " is an Invalid Layer Arn.")

        return layer_version