code: def load_logged_queries(params) -> Sequence[TrainingQuery]:
      logging.info("loading logged queries...")
      if "folder" not in params:
          raise Exception('Please define "folder" in "raw_data"')
      folder = params["folder"] if "folder" in params else ""
      if len(folder) == 0:
          folder = os.getcwd()
      cache_file_name = (
          params["cache_file_name"]
          if "cache_file_name" in params
          else ""
      )
      cache_file = os.path.join(folder, f"{cache_file_name}.pickle")
      if len(cache_file_name) > 0 and os.access(cache_file, os.R_OK):
          logging.info(f"  loading {cache_file}")
          try:
              st = time.perf_counter()
              with open(cache_file, "rb") as f:
                  logged_queries = pickle.load(f)
              logging.info(f"  loading time {time.perf_counter() - st}")
              return logged_queries
          except Exception as err:
              logging.warning(f" loading error {err}")
      base_file_name = (
          params["base_file_name"] if "base_file_name" in params else ""
      )
      if len(base_file_name) == 0:
          raise Exception('"base_file_name" not defined!')
      days = params["days"] if "days" in params else []
      all_queries = {}
      st = time.perf_counter()
      for day in days:
          pickle_file = os.path.join(
              folder, f"{base_file_name}_{day:02}.pickle"
          )
          if os.access(pickle_file, os.R_OK):
              logging.info(f"  loading {pickle_file}")
              with open(pickle_file, "rb") as f:
                  queries = pickle.load(f)
              if queries is None:
                  logging.warning(f"  loading {pickle_file} failed!")
              else:
                  logging.info(f"  loaded queries: {len(queries)}")
                  for q in queries:
                      if q.query_id in all_queries:
                          tq = all_queries[q.query_id]
                      else:
                          tq = TrainingQuery(q.query_id, q.query_terms)
                          all_queries[q.query_id] = tq
                      tq.add(q)
          else:
              logging.warning(f"  {pickle_file} not accessible!")
      logging.info(f"  loading time {time.perf_counter() - st}")
      logged_queries = tuple(all_queries.values())
      for v in logged_queries:
          v.finalize()
      if len(cache_file_name) > 0:
          logging.info(f"  saving logged queries to {cache_file}")
          try:
              st = time.perf_counter()
              with open(cache_file, "wb") as f:
                  pickle.dump(
                      logged_queries,
                      f,
                      protocol=pickle.HIGHEST_PROTOCOL,
                  )
              logging.info(f"  saving time {time.perf_counter() - st}")
          except Exception:
              logging.warning(f"  {cache_file} not accessible!")
      return logged_queries
  
imports: import argparse
  import json
  import logging
  import os
  import pickle
  import random
  import sys
  import time
  from typing import Iterable, List, Mapping, MutableMapping, Optional, Sequence, Tuple
  import numpy
  import torch
  import torch.multiprocessing
  from reagent.ope.estimators.estimator import Evaluator
  from reagent.ope.estimators.slate_estimators import DCGSlateMetric, ERRSlateMetric, FrechetDistribution, IPSEstimator, LogSample, NDCGSlateMetric, PBMEstimator, PseudoInverseEstimator, RankingDistribution, RewardDistribution, SlateContext, SlateEstimator, SlateEstimatorInput, SlateItemValues, SlateModel, SlateQuery, SlateSlots, SlateSlotValues
  from reagent.ope.utils import RunningAverage
label_desc: Use image node_id 3 for calling a global function with example usage: load_logged_queries(params) and returns: logged_queries, logged_queries