def _convert_reverse_sequence(builder, node, graph, err):
    """
    convert to CoreML Reverse Sequence Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L3577
    """
    batch_axis = node.attrs.get('batch_axis', 1)
    time_axis = node.attrs.get('time_axis', 0)
    output_name = node.outputs[0]
    add_transpose = False
    if batch_axis > time_axis:
        output_name += '_before_reverse'
        batch_axis, time_axis = time_axis, batch_axis
        add_transpose = True
    builder.add_reverse_sequence(name=node.name, input_names=node.inputs,
        output_name=output_name, batch_axis=batch_axis, seq_axis=time_axis)
    if add_transpose:
        output_name_post = '_before_reverse'
        rank = builder._get_rank(node.inputs[0])
        if rank == -1:
            return err.unsupported_op_configuration(builder, node, graph,
                'Rank unknown for input')
        axes = list(range(rank))
        axes[batch_axis], axes[time_axis] = axes[time_axis], axes[batch_axis]
        builder.add_transpose(name=node.name + '_transpose', axes=axes,
            input_name=output_name, output_name=node.outputs[0])
