<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_elimination_order(self, nodes=None):
 """ Returns the optimal elimination order based on the cost function. The node having the least cost is removed first. Parameters nodes: list, tuple, set (array-like) The variables which are to be eliminated. Examples -------- ['c', 's', 'l', 'd', 'g'] ['c', 's', 'l', 'd', 'g'] ['c', 's', 'l', 'd', 'g'] """

        if not nodes:
            nodes = self.bayesian_model.nodes()
        nodes = set(nodes)

        ordering = []
        while nodes:
            scores = {node: self.cost(node) for node in nodes}
            min_score_node = min(scores, key=scores.get)
            ordering.append(min_score_node)
            nodes.remove(min_score_node)
        return ordering