<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _finalize_memory(jvm_opts):
 """GRIDSS does not recommend setting memory between 32 and 48Gb. https://github.com/PapenfussLab/gridss#memory-usage """

    avoid_min = 32
    avoid_max = 48
    out_opts = []
    for opt in jvm_opts:
        if opt.startswith("-Xmx"):
            spec = opt[4:]
            val = int(spec[:-1])
            mod = spec[-1]
            if mod.upper() == "M":
                adjust = 1024
                min_val = avoid_min * 1024
                max_val = avoid_max * 1024
            else:
                adjust = 1
                min_val, max_val = avoid_min, avoid_max
            if val >= min_val and val < max_val:
                val = min_val - adjust
            opt = "%s%s%s" % (opt[:4], val, mod)
        out_opts.append(opt)
    return out_opts