def calculate(self, sources: Sequence[prensor.NodeTensor], destinations: Sequence[expression.Expression], options: calculate_options.Options, side_info: Optional[prensor.Prensor]=None) -> prensor.NodeTensor:
    [old_root_value, new_root_value] = sources
    if (isinstance(old_root_value, prensor.RootNodeTensor) and isinstance(new_root_value, prensor.ChildNodeTensor)):
        old_input_proto_index = _get_input_proto_index(old_root_value)
        return _RerootRootNodeTensor(tf.size(new_root_value.parent_index, out_type=tf.int64), tf.gather(old_input_proto_index, new_root_value.parent_index))
    raise ValueError('Source types incorrect')
def calculate(self, sources: Sequence[prensor.NodeTensor], destinations: Sequence[expression.Expression], options: calculate_options.Options, side_info: Optional[prensor.Prensor]=None) -> prensor.NodeTensor:
    [old_root_value, new_root_value] = sources
    if (isinstance(old_root_value, prensor.RootNodeTensor) and isinstance(new_root_value, prensor.ChildNodeTensor)):
        old_input_proto_index = _get_input_proto_index(old_root_value)
        return _RerootRootNodeTensor(tf.size(new_root_value.parent_index, out_type=tf.int64), tf.gather(old_input_proto_index, new_root_value.parent_index))
    raise ValueError('Source types incorrect')