class_docstr: Integration with the lightfm Recommender library.
code: def predict(
      self,
      df: Optional[pd.DataFrame] = None,
      args: Optional[dict] = None,
  ):
      predict_params = args["predict_params"]
  
      # if user doesn't specify recommender type, default to user_item
      try:
          recommender_type = df["recommender_type"].tolist()[0]
      except KeyError:
          recommender_type = predict_params.get(
              "recommender_type", "user_item"
          )
  
      args = self.model_storage.json_get("args")
  
      # get item_id to idx and user_id to idx maps
      args["item_id_to_idx_map"] = dict(
          zip(
              args["item_idx_to_id_map"].values(),
              args["item_idx_to_id_map"].keys(),
          )
      )
      args["user_id_to_idx_map"] = dict(
          zip(
              args["user_idx_to_id_map"].values(),
              args["user_idx_to_id_map"].keys(),
          )
      )
  
      model = dill.loads(self.model_storage.file_get("model"))
  
      n_users = args["n_users_items"][0]
      n_items = args["n_users_items"][1]
      item_ids, user_ids = None, None
  
      if recommender_type == "user_item":
          if df is not None:
              if args["item_id"] in df.columns:
                  n_items = df[args["item_id"]].nunique()
                  item_ids = df[args["item_id"]].unique().tolist()
  
              if args["user_id"] in df.columns:
                  n_users = df[args["user_id"]].nunique()
                  user_ids = df[args["user_id"]].unique().tolist()
  
          return get_user_item_recommendations(
              n_users=n_users,
              n_items=n_items,
              args=args,
              model=model,
              item_ids=item_ids,
              user_ids=user_ids,
          )
  
      elif recommender_type == "item_item":
          if df is not None and args["item_id"] in df.columns:
              item_ids = df[args["item_id"]].unique().tolist()
  
          return get_item_item_recommendations(
              model=model,
              args=args,
              item_ids=item_ids,
          )
  
      elif recommender_type == "user_user":
          raise NotImplementedError(
              "user_user recommendation type is not implemented yet"
          )
  
      else:
          raise ValueError(
              "recommender_type must be either 'user_item', 'item_item' or 'user_user'"
          )
  
file_path: mindsdb/mindsdb/integrations/handlers/lightfm_handler/lightfm_handler.py
imports: from typing import Dict, Optional
  import dill
  import pandas
  from dataprep_ml.recommenders import RecommenderPreprocessor
  from lightfm import LightFM
  from lightfm.cross_validation import random_train_test_split
  from lightfm.evaluation import auc_score, precision_at_k, recall_at_k
  from mindsdb.integrations.handlers.lightfm_handler.helpers import get_item_item_recommendations, get_user_item_recommendations
  from mindsdb.integrations.handlers.lightfm_handler.settings import ModelParameters
  from mindsdb.integrations.libs.base import BaseMLEngine
label_desc: Use image node_id 2 for calling the LightFMHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: get_user_item_recommendations, get_item_item_recommendations