The code successfully runs after I’ve switched to nightly release, cool! Thank you!
But there is bad news that new errors arise when the interpreter tries to compile other methods. For example:
@torch.jit.script
class Tree(object):
    def __init__(self):
        self.parent = torch.jit.annotate(Optional[Tree], None)

    def add_child(self, child):
        # type: (Tree) -> None
        child.parent = torch.jit.annotate(Optional[Tree], self)

When run to the last line, an error arises:
RuntimeError: 
expected an expression of type Optional[__torch__.Tree] but found __torch__.Tree:
at /Users/fere/repos/treelstm.pytorch/treelstm/tree.py:25:43
    def add_child(self, child):
        # type: (Tree) -> None
        child.parent = torch.jit.annotate(Optional[Tree], self)
                                          ~~~~~~~~~~~~~~~~~~~~ <--- HERE

The interpreter regards self as Tree instead of Optional[Tree], which makes sense but I thought that torch.jit.annotate should be able to do some casting work. The reason why I think so is that in code above, the interpreter takes torch.jit.annotate(Optional[Tree], None) as an Optional[Tree] type value instead of None. I’ve gone through the TorchScript documentation and done some searching, but the only method I’ve found that is able to specify types for a value other than function parameters and return values is by using torch.jit.annotate. Also, I haven’t find any ways which can cast a T typed value to an Optional[T] value. So I am curious that is there anything I miss?
Another problem is below:
@torch.jit.script
class Tree(object):
    def __init__(self):
        self.num_children = torch.jit.annotate(int, 0)

    def add_child(self):
        self.num_children += 1

Error:
RuntimeError: 
left-hand side of augmented assignment to module parameters/buffers can only be tensor types:
at /Users/fere/repos/treelstm.pytorch/treelstm/tree.py:15:9
    def add_child(self):
        self.num_children += 1
        ~~~~~~~~ <--- HERE

Does the error message means that only Tensor-typed values can be updated in a custom TorchScript class?
Thankful and grateful for your help!