code: def get_train_input(session, train_file_path, npratio=4):
      """Generate train file.
  
      Args:
          session (list): List of user session with user_id, clicks, positive and negative interactions.
          train_file_path (str): Path to file.
          npration (int): Ratio for negative sampling.
      """
      fp_train = open(train_file_path, "w", encoding="utf-8")
      for sess_id in range(len(session)):
          sess = session[sess_id]
          userid, _, poss, negs = sess
          for i in range(len(poss)):
              pos = poss[i]
              neg = _newsample(negs, npratio)
              fp_train.write(
                  "1 " + "train_" + userid + " " + pos + "\n"
              )
              for neg_ins in neg:
                  fp_train.write(
                      "0 " + "train_" + userid + " " + neg_ins + "\n"
                  )
      fp_train.close()
      if os.path.isfile(train_file_path):
          logger.info(
              f"Train file {train_file_path} successfully generated"
          )
      else:
          raise FileNotFoundError(
              f"Error when generating {train_file_path}"
          )
  
imports: import os
  import random
  import logging
  import json
  import numpy
  import re
  from tqdm import tqdm
  from nltk.tokenize import RegexpTokenizer
  from recommenders.datasets.download_utils import maybe_download, download_path, unzip_file
label_desc: Use image node_id 5 for calling a global function with example usage: get_train_input(session, train_file_path, npratio) without return types