<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nodes_by_attribute(self, attr_val, attr='type'):
 """ Select Graph's nodes by attribute value Get all nodes that share the same attribute. By default, the attr 'type' is used to specify the nodes type (generator, load, etc.). Examples -------- [1, 3] Parameters attr_val: str Value of the `attr` nodes should be selected by attr: str, default: 'type' Attribute key which is 'type' by default Returns ------- list A list containing nodes elements that match the given attribute value """


        temp_nodes = getattr(self, 'node')
        nodes = list(filter(None, map(lambda x: x if temp_nodes[x][attr] == attr_val else None,
                                      temp_nodes.keys())))

        return nodes