code: def interactions(df):
      movie_genre = [x.split("|") for x in df["genre"]]
      all_movie_genre = sorted(
          list(set(itertools.chain.from_iterable(movie_genre)))
      )
  
      all_occupations = sorted(list(set(df["occupation"])))
  
      dataset = Dataset()
      dataset.fit(
          df["userID"],
          df["itemID"],
          item_features=all_movie_genre,
          user_features=all_occupations,
      )
  
      item_features = dataset.build_item_features(
          (x, y) for x, y in zip(df.itemID, movie_genre)
      )
  
      user_features = dataset.build_user_features(
          (x, [y]) for x, y in zip(df.userID, df["occupation"])
      )
  
      (interactions, _) = dataset.build_interactions(
          df.iloc[:, 0:3].values
      )
  
      (
          train_interactions,
          test_interactions,
      ) = cross_validation.random_train_test_split(
          interactions,
          test_percentage=TEST_PERCENTAGE,
          random_state=np.random.RandomState(SEEDNO),
      )
      return (
          train_interactions,
          test_interactions,
          item_features,
          user_features,
      )
  
file_path: recommenders/tests/unit/recommenders/models/test_lightfm_utils.py
imports: import pytest
  import itertools
  import numpy
  import pandas
  from lightfm.data import Dataset
  from lightfm import LightFM, cross_validation
  from recommenders.models.lightfm.lightfm_utils import track_model_metrics, similar_users, similar_items
label_desc: Use image node_id 2 for calling a global function with example usage: interactions(df) and returns: train_interactions,  test_interactions,  item_features,  user_features