from typing import Union
import torch
from typing import Tuple
from typing import List


def reset_backward_rnn_state(
    states: Union[torch.Tensor, Tuple, List]
) -> Union[torch.Tensor, Tuple, List]:
    """Set backward BRNN states to zeroes.

    Args:
        states: RNN states

    Returns:
        states: RNN states with backward set to zeroes

    """
    if isinstance(states, (list, tuple)):
        for state in states:
            state[1::2] = 0.0
    else:
        states[1::2] = 0.0
    return states