If var_id is a python variable, then you just use it as a python variable.
With not quotes and no dollar sign:
pipeline= … "_id" : var_id
If var_id is a python variable, then you just use it as a python variable.
With not quotes and no dollar sign:
pipeline= … "_id" : var_id