reference: this patch is from WeNet wenet/runtime/core/patch