code: def construct_graph(
      datapath, session_interval_gap_sec, valid_sku_raw_ids
  ):
      user_clicks, sku_encoder, sku_decoder = parse_actions(
          datapath, valid_sku_raw_ids
      )
  
      # {src,dst: weight}
      graph = {}
      for user_id, action_list in user_clicks.items():
          # sort by action time
          _action_list = sorted(action_list, key=lambda x: x[1])
  
          last_action_time = datetime.strptime(
              _action_list[0][1], "%Y-%m-%d %H:%M:%S"
          )
          session = [_action_list[0][0]]
          # cut sessions and add to graph
          for sku_id, action_time in _action_list[1:]:
              action_time = datetime.strptime(
                  action_time, "%Y-%m-%d %H:%M:%S"
              )
              gap = action_time - last_action_time
              if gap.seconds < session_interval_gap_sec:
                  session.append(sku_id)
              else:
                  # here we have a new session
                  # add prev session to graph
                  add_session(session, graph)
                  # create a new session
                  session = [sku_id]
          # add last session
          add_session(session, graph)
  
      g = convert_to_dgl_graph(graph)
  
      return g, sku_encoder, sku_decoder
  
file_path: dgl/examples/pytorch/eges/utils.py
imports: import argparse
  import random
  from datetime import datetime
  import dgl
  import networkx
  import numpy
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: construct_graph(datapath, session_interval_gap_sec, valid_sku_raw_ids) and returns: g,  sku_encoder,  sku_decoder