code: def forward(
      self,
      x,
      get_hidden=False,
      train_hidden=None,
      train_hidden_day=None,
      k_day=10,
      n_neighbor=10,
  ):
      # x: [N, F*T]
      device = x.device
      x = x.reshape(len(x), self.d_feat, -1)  # [N, F, T]
      x = x.permute(0, 2, 1)  # [N, T, F]
      out, _ = self.rnn(x)
      out = out[:, -1, :]
      out = self.lins(out)
      mini_batch_out = out
      if get_hidden is True:
          return mini_batch_out
  
      mini_batch_out_day = torch.mean(mini_batch_out, dim=0).unsqueeze(
          0
      )
      day_similarity = self.cal_cos_similarity(
          mini_batch_out_day, train_hidden_day.to(device)
      )
      day_index = torch.topk(day_similarity, k_day, dim=1)[1]
      sample_train_hidden = train_hidden[
          day_index.long().cpu()
      ].squeeze()
      sample_train_hidden = torch.cat(list(sample_train_hidden)).to(
          device
      )
      sample_train_hidden = self.lins(sample_train_hidden)
      cos_similarity = self.cal_cos_similarity(
          self.project1(mini_batch_out),
          self.project2(sample_train_hidden),
      )
  
      row = (
          torch.linspace(0, x.shape[0] - 1, x.shape[0])
          .reshape([-1, 1])
          .repeat(1, n_neighbor)
          .reshape(1, -1)
          .to(device)
      )
      column = torch.topk(cos_similarity, n_neighbor, dim=1)[1].reshape(
          1, -1
      )
      mask = torch.sparse_coo_tensor(
          torch.cat([row, column]),
          torch.ones([row.shape[1]]).to(device) / n_neighbor,
          (x.shape[0], sample_train_hidden.shape[0]),
      )
      cos_similarity = self.sparse_dense_mul(mask, cos_similarity)
  
      agg_out = torch.sparse.mm(
          cos_similarity, self.project2(sample_train_hidden)
      )
      # out = self.fc_out(out).squeeze()
      out = self.fc_out_pred(
          torch.cat([mini_batch_out, agg_out], axis=1)
      ).squeeze()
      return out
  
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  import pandas
  from typing import Text, Union
  import copy
  from ...utils import get_or_create_path
  from ...log import get_module_logger
  import torch
  import torch.nn
  import torch.optim
  from .pytorch_utils import count_parameters
  from ...model.base import Model
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
  from ...contrib.model.pytorch_lstm import LSTMModel
  from ...contrib.model.pytorch_gru import GRUModel
label_desc: Use image node_id 4 for calling the IGMTFModel obj's underlying member method code with example usage: obj.forward(x, get_hidden, train_hidden, train_hidden_day, k_day, n_neighbor) and returns: out, mini_batch_out