class_docstr: DCNV2 improves the cross network by extending the original weight vector to a matrix,
  significantly improves the expressiveness of DCN. It also introduces the MoE and
  low rank techniques to reduce time cost.
class_docstr_tok: ["DCNV2","improves","the","cross","network","by","extending","the","original","weight","vector","to","a","matrix",",","significantly","improves","the","expressiveness","of","DCN",".","It","also","introduces","the","MoE","and","low","rank","techniques","to","reduce","time","cost","."]
docstr: Cross network part of DCN-mix, which add MoE and nonlinear transformation in low-rank space.
  
  .. math::
      x_{l+1} = \sum_{i=1}^K G_i(x_l)E_i(x_l)+x_l
  .. math::
      E_i(x_l) = x_0 \odot (U_l^i \dot g(C_l^i \dot g(V_L^{iT} x_l)) + b_l)
  
  :math:`E_i` and :math:`G_i` represents the expert and gatings respectively,
  :math:`U_l`, :math:`C_l`, :math:`V_l` stand for low-rank decomposition of weight matrix,
  :math:`g` is the nonlinear activation function.
  
  Args:
      x_0(torch.Tensor): Embedding vectors of all features, input of cross network.
  
  Returns:
      torch.Tensor:output of mixed cross network, [batch_size, num_feature_field * embedding_size]
docstr_tok: ["Cross","network","part","of","DCN-mix",",","which","add","MoE","and","nonlinear","transformation","in","low-rank","space",".","..","math",":",":","x_","{","l+1","}","=","\\sum_","{","i=1","}","^K","G_i","(","x_l",")","E_i","(","x_l",")","+x_l","..","math",":",":","E_i","(","x_l",")","=","x_0","\\odot","(","U_l^i","\\dot","g","(","C_l^i","\\dot","g","(","V_L^","{","iT","}","x_l",")",")","+","b_l",")",":","math",":","`","E_i","`","and",":","math",":","`","G_i","`","represents","the","expert","and","gatings","respectively",",",":","math",":","`","U_l","`",",",":","math",":","`","C_l","`",",",":","math",":","`","V_l","`","stand","for","low-rank","decomposition","of","weight","matrix",",",":","math",":","`","g","`","is","the","nonlinear","activation","function",".","Args",":","x_0","(","torch.Tensor",")",":","Embedding","vectors","of","all","features",",","input","of","cross","network",".","Returns",":","torch.Tensor",":","output","of","mixed","cross","network",",","[","batch_size",",","num_feature_field","*","embedding_size","]"]
code: def cross_network_mix(self, x_0):
      r"""Cross network part of DCN-mix, which add MoE and nonlinear transformation in low-rank space.
  
      .. math::
          x_{l+1} = \sum_{i=1}^K G_i(x_l)E_i(x_l)+x_l
      .. math::
          E_i(x_l) = x_0 \odot (U_l^i \dot g(C_l^i \dot g(V_L^{iT} x_l)) + b_l)
  
      :math:`E_i` and :math:`G_i` represents the expert and gatings respectively,
      :math:`U_l`, :math:`C_l`, :math:`V_l` stand for low-rank decomposition of weight matrix,
      :math:`g` is the nonlinear activation function.
  
      Args:
          x_0(torch.Tensor): Embedding vectors of all features, input of cross network.
  
      Returns:
          torch.Tensor:output of mixed cross network, [batch_size, num_feature_field * embedding_size]
      """
      x_0 = x_0.unsqueeze(dim=2)
      x_l = x_0  # (batch_size, in_feature_num, 1)
      for i in range(self.cross_layer_num):
          expert_output_list = []
          gating_output_list = []
          for expert in range(self.expert_num):
              # compute gating output
              gating_output_list.append(
                  self.gating[expert](x_l.squeeze(dim=2))
              )  # (batch_size, 1)
  
              # project to low-rank subspace
              xl_v = torch.matmul(
                  self.cross_layer_v[i][expert].T, x_l
              )  # (batch_size, low_rank, 1)
  
              # nonlinear activation in subspace
              xl_c = self.tanh(xl_v)
              xl_c = torch.matmul(
                  self.cross_layer_c[i][expert], xl_c
              )  # (batch_size, low_rank, 1)
              xl_c = self.tanh(xl_c)
  
              # project back feature space
              xl_u = torch.matmul(
                  self.cross_layer_u[i][expert], xl_c
              )  # (batch_size, in_feature_num, 1)
  
              # dot with x_0
              xl_dot = xl_u + self.bias[i]
              xl_dot = torch.mul(x_0, xl_dot)
  
              expert_output_list.append(
                  xl_dot.squeeze(dim=2)
              )  # (batch_size, in_feature_num)
  
          expert_output = torch.stack(
              expert_output_list, dim=2
          )  # (batch_size, in_feature_num, expert_num)
          gating_output = torch.stack(
              gating_output_list, dim=1
          )  # (batch_size, expert_num, 1)
          moe_output = torch.matmul(
              expert_output, self.softmax(gating_output)
          )  # (batch_size, in_feature_num, 1)
          x_l = x_l + moe_output
  
      x_l = x_l.squeeze(dim=2)  # (batch_size, in_feature_num)
      return x_l
  
file_path: RecBole/recbole/model/context_aware_recommender/dcnv2.py
imports: import torch
  import torch.nn
  from recbole.model.abstract_recommender import ContextRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.layers import MLPLayers
  from recbole.model.loss import RegLoss
label_desc: Use image node_id 3 for calling the DCNV2 obj's underlying member method code with example usage: obj.cross_network_mix(x_0) and returns: x_l