code: def df_to_interactions(
      df: pd.DataFrame,
      user_col: str = "user_id",
      item_col: str = "item_id",
      ratings_col: Optional[str] = "rating",
      **kwargs,
  ) -> Interactions:
      """
      Helper function to convert a DataFrame to an ``Interactions`` object.
  
      Parameters
      ----------
      df: pd.DataFrame
          Dataframe with columns for user IDs, item IDs, and (optionally) ratings
      user_col: str
          Column name for the user IDs
      item_col: str
          Column name for the item IDs
      ratings_col: str
          Column name for the ratings column. If ``None``, will default to ratings of all 1s
      **kwargs
          Keyword arguments to pass to ``Interactions``
  
      Returns
      -------
      interactions: collie.interactions.Interactions
  
      """
      ratings = df[ratings_col] if ratings_col is not None else None
  
      return Interactions(
          users=df[user_col],
          items=df[item_col],
          ratings=ratings,
          **kwargs,
      )
  
imports: from datetime import datetime
  import inspect
  from pathlib import Path
  import re
  import time
  from typing import Any, Dict, Iterable, List, Optional, Union
  import docstring_parser
  import numpy
  import pandas
  import pytorch_lightning
  from scipy.sparse import coo_matrix
  import torch
  from collie.interactions import Interactions
label_desc: Use image node_id 5 for calling a global function with example usage: df_to_interactions(df, user_col, item_col, ratings_col) and returns: Interactions