Merge "Unify set_contexts() function for encoder and decoder" into nextgenv2