code: def _tgrep_nltk_tree_pos_action(_s, _l, tokens):
      """
      Builds a lambda function representing a predicate on a tree node
      which returns true if the node is located at a specific tree
      position.
      """
      # recover the tuple from the parsed string
      node_tree_position = tuple(int(x) for x in tokens if x.isdigit())
      # capture the node's tree position
      return (
          lambda i: lambda n, m=None, l=None: (
              hasattr(n, "treeposition") and n.treeposition() == i
          )
      )(node_tree_position)
  
imports: import functools
  import re
  import nltk.tree
label_desc: Use image node_id 16 for calling a global function with example usage: _tgrep_nltk_tree_pos_action(_s, _l, tokens) and returns: function