<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_rs_alg(r):
 """Parse resampling algorithm """

    #Note:GRA_CubicSpline created huge block artifacts for the St. Helen's compute_dh WV cases
    #Stick with CubicSpline for both upsampling/downsampling for now
    if r == 'near':
        #Note: Nearest respects nodata when downsampling
        gra = gdal.GRA_NearestNeighbour
    elif r == 'bilinear':
        gra = gdal.GRA_Bilinear
    elif r == 'cubic':
        gra = gdal.GRA_Cubic
    elif r == 'cubicspline':
        gra = gdal.GRA_CubicSpline
    elif r == 'average':
        gra = gdal.GRA_Average
    elif r == 'lanczos':
        gra = gdal.GRA_Lanczos
    elif r == 'mode':
        #Note: Mode respects nodata when downsampling, but very slow
        gra = gdal.GRA_Mode
    else:
        gra = None
        sys.exit("Invalid resampling method")
    return gra