I encountered this error for the below code snippet.
def init(self, original_dim, projection_dim, n_modalities=2):
super().init()
    self.C = []
    self.n_modalities = n_modalities

    for _ in range(n_modalities):
        # C tensor performs the mapping of the h vector and stores the s vector values as well
        C = torch.zeros(original_dim, projection_dim)
        for i in range(original_dim):
            C[i, np.random.randint(0, projection_dim-1)] = 2 * \
                np.random.randint(0, 2) - 1  # s values

        self.C.append(C)

def to(self, device):
    for i in range(len(self.C)):
        self.C[i].to(device)

def forward(self, *x):
    feature_size = x[0].size()
    y = [0]*self.n_modalities

    for i, d in enumerate(x):
        y[i] = d.mm(self.C[i]).view(feature_size[0], -1) # Error line