def print_tensor(td_tensor, indent="|   ", max_depth=-1, depth=0):
    """ print_tensor(td_tensor, indent="    ", max_depth=-1)
    Prints the dependency graph of a :py:class:`Tensor` *td_tensor*, where each new level is
    indented by *indent*. When *max_depth* is positive, the graph is truncated at that depth, where
    each tensor and each op count as a level.
    """
    offset = depth * indent
    line = "td tensor: %s" % td_tensor.name
    if td_tensor.value is not None:
        line += " (%s)" % (",".join(str(i) for i in td_tensor.value.shape),)

    print(offset + line)

    if td_tensor.op and (max_depth < 0 or max_depth > depth):
        print_op(td_tensor.op, indent=indent, max_depth=max_depth, depth=depth+1)