code: def get_item_user_idx(
      args: dict, n_users, n_items, item_ids=None, user_ids=None
  ):
      """
      gets item and user idxs from item_ids and user_ids
      :param args:
      :param n_users:
      :param n_items:
      :param item_ids:
      :param user_ids:
      :return:
      """
      if item_ids and user_ids:
          item_idx = np.array(
              [
                  int(args["item_id_to_idx_map"][item_id])
                  for item_id in item_ids
              ]
          )
          user_idx = np.array(
              [
                  int(args["user_id_to_idx_map"][user_id])
                  for user_id in user_ids
              ]
          )
  
          # repeat each user id index n_items times
          user_idxs = np.repeat(user_idx, n_items)
  
          # repeat the full list of item indexes n_user times
          item_idxs = np.tile(item_idx, n_users)
  
      elif item_ids and not user_ids:
          item_idx = np.array(
              [
                  int(args["item_id_to_idx_map"][item_id])
                  for item_id in item_ids
              ]
          )
  
          user_idxs = np.repeat([i for i in range(0, n_users)], n_items)
          item_idxs = np.tile(item_idx, n_users)
  
      elif user_ids and not item_ids:
          user_idx = np.array(
              [
                  int(args["user_id_to_idx_map"][user_id])
                  for user_id in user_ids
              ]
          )
  
          user_idxs = np.repeat(user_idx, n_items)
          item_idxs = np.tile([i for i in range(0, n_items)], n_users)
  
      else:
          user_idxs = np.repeat([i for i in range(0, n_users)], n_items)
          item_idxs = np.tile([i for i in range(0, n_items)], n_users)
  
      return item_idxs, user_idxs
  
imports: import lightfm
  import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: get_item_user_idx(args, n_users, n_items, item_ids, user_ids) and returns: item_idxs,  user_idxs