class_docstr: This is Field-Aware Factorization Machine Module for FFM.
code: def __init__(
      self,
      feature_names,
      feature_dims,
      feature2id,
      feature2field,
      num_fields,
      embed_dim,
      device,
  ):
      super(FieldAwareFactorizationMachine, self).__init__()
  
      self.token_feature_names = feature_names[0]
      self.float_feature_names = feature_names[1]
      self.token_seq_feature_names = feature_names[2]
      self.float_seq_feature_names = feature_names[3]
      self.token_feature_dims = feature_dims[0]
      self.float_feature_dims = feature_dims[1]
      self.token_seq_feature_dims = feature_dims[2]
      self.float_seq_feature_dims = feature_dims[3]
  
      self.feature2id = feature2id
      self.feature2field = feature2field
      self.num_features = (
          len(self.token_feature_names)
          + len(self.float_feature_names)
          + len(self.token_seq_feature_names)
          + len(self.float_seq_feature_names)
      )
      self.num_fields = num_fields
      self.embed_dim = embed_dim
      self.device = device
  
      # init token field-aware embeddings if there is token type of features.
      if len(self.token_feature_names) > 0:
          self.num_token_features = len(self.token_feature_names)
          self.token_embeddings = torch.nn.ModuleList(
              [
                  nn.Embedding(
                      sum(self.token_feature_dims), self.embed_dim
                  )
                  for _ in range(self.num_fields)
              ]
          )
          self.token_offsets = np.array(
              (0, *np.cumsum(self.token_feature_dims)[:-1]),
              dtype=np.long,
          )
          for embedding in self.token_embeddings:
              nn.init.xavier_uniform_(embedding.weight.data)
      # init float field-aware embeddings if there is float type of features.
      if len(self.float_feature_names) > 0:
          self.num_float_features = len(self.float_feature_names)
          self.float_offsets = np.array(
              (0, *np.cumsum(self.float_feature_dims)[:-1]),
              dtype=np.long,
          )
          self.float_embeddings = torch.nn.ModuleList(
              [
                  nn.Embedding(
                      sum(self.float_feature_dims), self.embed_dim
                  )
                  for _ in range(self.num_fields)
              ]
          )
          for embedding in self.float_embeddings:
              nn.init.xavier_uniform_(embedding.weight.data)
      # init token_seq field-aware embeddings if there is token_seq type of features.
      if len(self.token_seq_feature_names) > 0:
          self.num_token_seq_features = len(
              self.token_seq_feature_names
          )
          self.token_seq_embeddings = torch.nn.ModuleList()
          self.token_seq_embedding = torch.nn.ModuleList()
          for i in range(self.num_fields):
              for token_seq_feature_dim in self.token_seq_feature_dims:
                  self.token_seq_embedding.append(
                      nn.Embedding(
                          token_seq_feature_dim, self.embed_dim
                      )
                  )
              for embedding in self.token_seq_embedding:
                  nn.init.xavier_uniform_(embedding.weight.data)
              self.token_seq_embeddings.append(self.token_seq_embedding)
      if len(self.float_seq_feature_names) > 0:
          self.num_float_seq_features = len(
              self.float_seq_feature_names
          )
          self.float_seq_embeddings = torch.nn.ModuleList()
          self.float_seq_embedding = torch.nn.ModuleList()
          for i in range(self.num_fields):
              for float_seq_feature_dim in self.float_seq_feature_dims:
                  self.float_seq_embedding.append(
                      nn.Embedding(
                          float_seq_feature_dim, self.embed_dim
                      )
                  )
              for embedding in self.float_seq_embedding:
                  nn.init.xavier_uniform_(embedding.weight.data)
              self.float_seq_embeddings.append(self.float_seq_embedding)
  
imports: import numpy
  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 1 to create a new FieldAwareFactorizationMachine object from inherited base classes: nn with example: obj = FieldAwareFactorizationMachine(feature_names, feature_dims, feature2id, feature2field, num_fields, embed_dim, device)