<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_nodes(self, states=None):
 """Get the status of nodes in the cluster. Parameters states : sequence of NodeState, optional If provided, nodes will be filtered to these node states. Default is all states. Returns ------- reports : list of NodeReport Examples -------- Get all the running nodes [NodeReport<id='worker1.example.com:34721'>, NodeReport<id='worker2.example.com:34721'>] """

        if states is not None:
            states = tuple(NodeState(s) for s in states)
        else:
            states = ()

        req = proto.NodesRequest(states=[str(s) for s in states])
        resp = self._call('getNodes', req)
        return sorted((NodeReport.from_protobuf(r) for r in resp.reports),
                      key=lambda x: x.id)