def test_same_over_batch(self):
    '\n        Tests if the outputs of the cell are the same over the batch if the same input is fed in multiple times.\n        '
    toy_input_dim = 4
    toy_batch_size = 7
    toy_state_dim = 3
    toy_x = torch.Tensor([1.5, 4.2, 3.1415, 2.71]).expand(toy_batch_size, toy_input_dim)
    toy_s_prev_hor = torch.Tensor([(- 0.4), 1.2, 42.195]).expand(toy_batch_size, toy_state_dim)
    toy_s_prev_ver = torch.Tensor([2.3, 7.12, (- 3.14)]).expand(toy_batch_size, toy_state_dim)
    toy_c_prev_hor = torch.Tensor([(- 10.1), 4.5, (- 0.1)]).expand(toy_batch_size, toy_state_dim)
    toy_c_prev_ver = torch.Tensor([17, 1.001, (- 2.23)]).expand(toy_batch_size, toy_state_dim)
    cell = LSTM2dCell(toy_input_dim, toy_state_dim, self.device)
    (c, s) = cell.forward(x=toy_x, s_prev_hor=toy_s_prev_hor, s_prev_ver=toy_s_prev_ver, c_prev_hor=toy_c_prev_hor, c_prev_ver=toy_c_prev_ver)
    c_first = c[0, :]
    repeated_c_first = c_first.expand(toy_batch_size, c_first.shape[(- 1)])
    self.assertTrue(repeated_c_first.allclose(c), 'Next cell state varies across same-input batch')
    s_first = s[0, :]
    repeated_s_first = s_first.expand(toy_batch_size, s_first.shape[(- 1)])
    self.assertTrue(repeated_s_first.allclose(s), 'Next hidden state varies across same-input batch')
Tests if the outputs of the cell are the same over the batch if the same input is fed in multiple times.
def test_same_over_batch(self):
    '\n        \n        '
    toy_input_dim = 4
    toy_batch_size = 7
    toy_state_dim = 3
    toy_x = torch.Tensor([1.5, 4.2, 3.1415, 2.71]).expand(toy_batch_size, toy_input_dim)
    toy_s_prev_hor = torch.Tensor([(- 0.4), 1.2, 42.195]).expand(toy_batch_size, toy_state_dim)
    toy_s_prev_ver = torch.Tensor([2.3, 7.12, (- 3.14)]).expand(toy_batch_size, toy_state_dim)
    toy_c_prev_hor = torch.Tensor([(- 10.1), 4.5, (- 0.1)]).expand(toy_batch_size, toy_state_dim)
    toy_c_prev_ver = torch.Tensor([17, 1.001, (- 2.23)]).expand(toy_batch_size, toy_state_dim)
    cell = LSTM2dCell(toy_input_dim, toy_state_dim, self.device)
    (c, s) = cell.forward(x=toy_x, s_prev_hor=toy_s_prev_hor, s_prev_ver=toy_s_prev_ver, c_prev_hor=toy_c_prev_hor, c_prev_ver=toy_c_prev_ver)
    c_first = c[0, :]
    repeated_c_first = c_first.expand(toy_batch_size, c_first.shape[(- 1)])
    self.assertTrue(repeated_c_first.allclose(c), 'Next cell state varies across same-input batch')
    s_first = s[0, :]
    repeated_s_first = s_first.expand(toy_batch_size, s_first.shape[(- 1)])
    self.assertTrue(repeated_s_first.allclose(s), 'Next hidden state varies across same-input batch')