<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def node2bracket(docgraph, node_id, child_str=''):
 """convert a docgraph node into a PTB-style string."""

    node_attrs = docgraph.node[node_id]
    if istoken(docgraph, node_id):
        pos_str = node_attrs.get(docgraph.ns+':pos', '')
        token_str = node_attrs[docgraph.ns+':token']
        return u"({pos}{space1}{token}{space2}{child})".format(
            pos=pos_str, space1=bool(pos_str)*' ', token=token_str,
            space2=bool(child_str)*' ', child=child_str)

    #else: node is not a token
    label_str = node_attrs.get('label', '')
    return u"({label}{space}{child})".format(
        label=label_str, space=bool(label_str and child_str)*' ',
        child=child_str)