def _rindex(sequence: Sequence[T], obj: T) -> int:
    """
    Return zero-based index in the sequence of the last item whose value is equal to obj.  Raises a
    ValueError if there is no such item.

    # Parameters

    sequence : `Sequence[T]`
    obj : `T`

    # Returns

    `int`
        zero-based index associated to the position of the last item equal to obj
    """
    for i in range(len(sequence) - 1, -1, -1):
        if sequence[i] == obj:
            return i

    raise ValueError(f"Unable to find {obj} in sequence {sequence}.")
Return zero-based index in the sequence of the last item whose value is equal to obj.  Raises a
ValueError if there is no such item.

# Parameters

sequence : `Sequence[T]`
obj : `T`

# Returns

`int`
zero-based index associated to the position of the last item equal to obj
allennlp/nn/util.py