title: TypeError: only integer tensors of a single element can be converted to an index
body: <p>The following is the error information with pytorch:</p>
  <p>TypeError: only integer tensors of a single element can be converted to an index</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;Main_mine.py&quot;, line 377, in &lt;module&gt;
      best_model, [losses_train, losses_valid, losses_epochs_train, losses_epochs_valid] = Train_Model(grud, train_dataloader, valid_dataloader , lr, epochs,patience)
    File &quot;Main_mine.py&quot;, line 206, in Train_Model
      outputs = model(inputs)
    File &quot;/home/alaa/.local/lib/python3.5/site-packages/torch/nn/modules/module.py&quot;, line 532, in __call__
      result = self.forward(*input, **kwargs)
    File &quot;/media/alaa/New Drive2/PHD/PHD3-Missing Values/Codes/archive(1)/run/GRU-D_my_version/LSTMD_mine.py&quot;, line 168, in forward
      , torch.squeeze(Delta[:,i:i+1,:]))
    File &quot;/media/alaa/New Drive2/PHD/PHD3-Missing Values/Codes/archive(1)/run/GRU-D_my_version/LSTMD_mine.py&quot;, line 135, in step
      h = ((delta_h * h))
  TypeError: only integer tensors of a single element can be converted to an index.
  
  </code></pre>
  <p>The following is the code:</p>
  <pre><code>def step(self, x, x_last_obsv, x_mean, h, ct, mask, delta): 
          batch_size = x.shape[0]
          dim_size = x.shape[1]
          
          delta_x = torch.exp(-torch.max(self.zeros_x, self.gamma_x_l(delta)))
          delta_h = torch.exp(-torch.max(self.zeros_h, self.gamma_h_l(delta)))
          
          x = mask * x + (1 - mask) * (delta_x * x_last_obsv + (1 - delta_x) * x_mean)
          h = ((delta_h * h))
          
          combined = torch.cat((x, h, mask), 1)
          f = F.sigmoid(self.fl(combined))
          i = F.sigmoid(self.il(combined))
          o = F.sigmoid(self.fl(combined))
          c = F.tanh(self.cl(combined))
          ct=f*ct + i*c
          h= (torch.round(o* torch.tanh(ct)))
          return h,ct
  
  </code></pre>