def _try_to_merge_state_ops():
        """
        We detect the pattern of:

            %1 = coreml_update_state(state=%state, value=%value)
            %2 = read_state(input=%state)

        and transform it into:

            %2 = coreml_update_state(state=%state, value=%value)
        """
        block = curr_block()

        if len(block.operations) < 2:
            return

        op_1, op_2 = block.operations.end.prev.op, block.operations.end.op
        if op_1.op_type != "coreml_update_state" or op_2.op_type != "read_state":
            return
        if op_1.state != op_2.input:
            return

        var_1, var_2 = op_1.outputs[0], op_2.outputs[0]
        var_1.name = var_2.name
        context.register_var_with_name(var_1.name, var_1)
        block.remove_ops([op_2])

        We detect the pattern of:

            %1 = coreml_update_state(state=%state, value=%value)
            %2 = read_state(input=%state)

        and transform it into:

            %2 = coreml_update_state(state=%state, value=%value)
        
coremltools/converters/mil/frontend/milproto/load.py