class_docstr: xDeepFM combines a CIN (Compressed Interaction Network) with a classical DNN.
  The model is able to learn certain bounded-degree feature interactions explicitly;
  Besides, it can also learn arbitrary low- and high-order feature interactions implicitly.
class_docstr_tok: ["xDeepFM","combines","a","CIN","(","Compressed","Interaction","Network",")","with","a","classical","DNN",".","The","model","is","able","to","learn","certain","bounded-degree","feature","interactions","explicitly",";","Besides",",","it","can","also","learn","arbitrary","low-","and","high-order","feature","interactions","implicitly","."]
docstr: For k-th CIN layer, the output :math:`X_k` is calculated via
  
  .. math::
      x_{h,*}^{k} = \sum_{i=1}^{H_k-1} \sum_{j=1}^{m}W_{i,j}^{k,h}(X_{i,*}^{k-1} \circ x_{j,*}^0)
  
  :math:`H_k` donates the number of feature vectors in the k-th layer,
  :math:`1 \le h \le H_k`.
  :math:`\circ` donates the Hadamard product.
  
  And Then, We apply sum pooling on each feature map of the hidden layer.
  Finally, All pooling vectors from hidden layers are concatenated.
  
  Args:
      input_features(torch.Tensor): [batch_size, field_num, embed_dim]. Embedding vectors of all features.
      activation(str): name of activation function.
  
  Returns:
      torch.Tensor: [batch_size, num_feature_field * embedding_size]. output of CIN layer.
docstr_tok: ["For","k-th","CIN","layer",",","the","output",":","math",":","`","X_k","`","is","calculated","via","..","math",":",":","x_","{","h",",","*","}","^","{","k","}","=","\\sum_","{","i=1","}","^","{","H_k-1","}","\\sum_","{","j=1","}","^","{","m","}","W_","{","i",",","j","}","^","{","k",",","h","}","(","X_","{","i",",","*","}","^","{","k-1","}","\\circ","x_","{","j",",","*","}","^0",")",":","math",":","`","H_k","`","donates","the","number","of","feature","vectors","in","the","k-th","layer",",",":","math",":","`","1","\\le","h","\\le","H_k","`",".",":","math",":","`","\\circ","`","donates","the","Hadamard","product",".","And","Then",",","We","apply","sum","pooling","on","each","feature","map","of","the","hidden","layer",".","Finally",",","All","pooling","vectors","from","hidden","layers","are","concatenated",".","Args",":","input_features","(","torch.Tensor",")",":","[","batch_size",",","field_num",",","embed_dim","]",".","Embedding","vectors","of","all","features",".","activation","(","str",")",":","name","of","activation","function",".","Returns",":","torch.Tensor",":","[","batch_size",",","num_feature_field","*","embedding_size","]",".","output","of","CIN","layer","."]
code: def compressed_interaction_network(
      self, input_features, activation="ReLU"
  ):
      r"""For k-th CIN layer, the output :math:`X_k` is calculated via
  
      .. math::
          x_{h,*}^{k} = \sum_{i=1}^{H_k-1} \sum_{j=1}^{m}W_{i,j}^{k,h}(X_{i,*}^{k-1} \circ x_{j,*}^0)
  
      :math:`H_k` donates the number of feature vectors in the k-th layer,
      :math:`1 \le h \le H_k`.
      :math:`\circ` donates the Hadamard product.
  
      And Then, We apply sum pooling on each feature map of the hidden layer.
      Finally, All pooling vectors from hidden layers are concatenated.
  
      Args:
          input_features(torch.Tensor): [batch_size, field_num, embed_dim]. Embedding vectors of all features.
          activation(str): name of activation function.
  
      Returns:
          torch.Tensor: [batch_size, num_feature_field * embedding_size]. output of CIN layer.
      """
      batch_size, _, embedding_size = input_features.shape
      hidden_nn_layers = [input_features]
      final_result = []
      for i, layer_size in enumerate(self.cin_layer_size):
          z_i = torch.einsum(
              "bhd,bmd->bhmd", hidden_nn_layers[-1], hidden_nn_layers[0]
          )
          z_i = z_i.view(
              batch_size,
              self.field_nums[0] * self.field_nums[i],
              embedding_size,
          )
          z_i = self.conv1d_list[i](z_i)
  
          # Pass the CIN intermediate result through the activation function.
          if activation.lower() == "identity":
              output = z_i
          else:
              activate_func = activation_layer(activation)
              if activate_func is None:
                  output = z_i
              else:
                  output = activate_func(z_i)
  
          # Get the output of the hidden layer.
          if self.direct:
              direct_connect = output
              next_hidden = output
          else:
              if i != len(self.cin_layer_size) - 1:
                  next_hidden, direct_connect = torch.split(
                      output, 2 * [layer_size // 2], 1
                  )
              else:
                  direct_connect = output
                  next_hidden = 0
  
          final_result.append(direct_connect)
          hidden_nn_layers.append(next_hidden)
      result = torch.cat(final_result, dim=1)
      result = torch.sum(result, -1)
      return result
  
file_path: RecBole/recbole/model/context_aware_recommender/xdeepfm.py
imports: import torch
  import torch.nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import ContextRecommender
  from recbole.model.layers import MLPLayers, activation_layer
label_desc: Use image node_id 5 for calling the xDeepFM obj's underlying member method code with example usage: obj.compressed_interaction_network(input_features, activation) and returns: result