<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _marginalize_factor(self, nodes, factor):
 """ Marginalizing the factor selectively for a set of variables. Parameters: nodes: list, array-like A container of nodes (list, dict, set, etc.). factor: factor factor which is to be marginalized. """

        marginalizing_nodes = list(set(factor.scope()).difference(nodes))
        return factor.marginalize(marginalizing_nodes, inplace=False)