def _idx_to_conv(idx, conv_width, anchors_per_loc):
    """
    Converts an anchor box index in a 1-d numpy array to its corresponding 3-d index representing its convolution
    position and anchor index.
    :param idx: non-negative integer, the position in a 1-d numpy array of anchors.
    :param conv_width: the number of possible horizontal positions the convolutional layer's filters can occupy, i.e.
    close to the width in pixels divided by the cumulative stride at that layer.
    :param anchors_per_loc: positive integer, the number of anchors at each convolutional filter position.
    :return: tuple of the row, column, and anchor index of the convolutional filter position for this index.
    """
    divisor = conv_width * anchors_per_loc
    y, remainder = idx // divisor, idx % divisor
    x, anchor_idx = remainder // anchors_per_loc, remainder % anchors_per_loc
    return y, x, anchor_idx