import megengine.module as M
import megengine.functional as F


class FlowHead(M.Module):
    def __init__(self, input_dim=128, hidden_dim=256):
        super(FlowHead, self).__init__()
        self.conv1 = M.Conv2d(input_dim, hidden_dim, 3, padding=1)
        self.conv2 = M.Conv2d(hidden_dim, 2, 3, padding=1)
        self.relu = M.ReLU()

    def forward(self, x):
        return self.conv2(self.relu(self.conv1(x)))


class SepConvGRU(M.Module):
    def __init__(self, hidden_dim=128, input_dim=192 + 128):
        super(SepConvGRU, self).__init__()
        self.convz1 = M.Conv2d(
            hidden_dim + input_dim, hidden_dim, (1, 5), padding=(0, 2)
        )
        self.convr1 = M.Conv2d(
            hidden_dim + input_dim, hidden_dim, (1, 5), padding=(0, 2)
        )
        self.convq1 = M.Conv2d(
            hidden_dim + input_dim, hidden_dim, (1, 5), padding=(0, 2)
        )

        self.convz2 = 
M.Conv2d(
            hidden_dim + input_dim, hidden_dim, (5, 1), pa