class_docstr: FwFM is a context-based recommendation model. It aims to model the different feature interactions
  between different fields in a much more memory-efficient way. It proposes a field pair weight matrix
  :math:`r_{F(i),F(j)}`, to capture the heterogeneity of field pair interactions.
  
  The model defines as follows:
  
  .. math::
     y = w_0 + \sum_{i=1}^{m}x_{i}w_{i} + \sum_{i=1}^{m}\sum_{j=i+1}^{m}x_{i}x_{j}<v_{i}, v_{j}>r_{F(i),F(j)}
class_docstr_tok: ["FwFM","is","a","context-based","recommendation","model",".","It","aims","to","model","the","different","feature","interactions","between","different","fields","in","a","much","more","memory-efficient","way",".","It","proposes","a","field","pair","weight","matrix",":","math",":","`","r_","{","F","(","i",")",",","F","(","j",")","}","`",",","to","capture","the","heterogeneity","of","field","pair","interactions",".","The","model","defines","as","follows",":","..","math",":",":","y","=","w_0","+","\\sum_","{","i=1","}","^","{","m","}","x_","{","i","}","w_","{","i","}","+","\\sum_","{","i=1","}","^","{","m","}","\\sum_","{","j=i+1","}","^","{","m","}","x_","{","i","}","x_","{","j","}","<","v_","{","i","}",",","v_","{","j","}",">","r_","{","F","(","i",")",",","F","(","j",")","}"]
docstr: Create a mapping between features and fields.
docstr_tok: ["Create","a","mapping","between","features","and","fields","."]
code: def _get_feature2field(self):
      r"""Create a mapping between features and fields."""
      fea_id = 0
      for names in self.feature_names:
          if names is not None:
              for name in names:
                  self.feature2id[name] = fea_id
                  fea_id += 1
  
      if self.fields is None:
          field_id = 0
          for key, value in self.feature2id.items():
              self.feature2field[self.feature2id[key]] = field_id
              field_id += 1
      else:
          for key, value in self.fields.items():
              for v in value:
                  try:
                      self.feature2field[self.feature2id[v]] = key
                  except:
                      pass
  
file_path: RecBole/recbole/model/context_aware_recommender/fwfm.py
imports: import torch
  import torch.nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import ContextRecommender
label_desc: Use image node_id 3 for calling the FwFM obj's underlying member method code with example usage: obj._get_feature2field() without return types