code: def split_workload(in_file, clean=True):
      """Split a log file into separate files, each of which contains only a single workload
      This function can also delete duplicated records in log file
  
      Parameters
      ----------
      in_file: str
          input filename
      clean: bool
          whether delete duplicated items
      """
      tic = time.time()
      lines = list(open(in_file).readlines())
  
      logger.info("start converting...")
      pool = popen_pool.PopenPoolExecutor()
      lines = [
          rec for rec in pool.map(decode, lines) if rec is not None
      ]
      logger.info("map done %.2f", time.time() - tic)
  
      wkl_dict = OrderedDict()
      for inp, res in lines:
          wkl = measure_str_key(inp, False)
          if wkl not in wkl_dict:
              wkl_dict[wkl] = []
          wkl_dict[wkl].append([inp, res])
  
      if clean:
          for i, (k, v) in enumerate(wkl_dict.items()):
              # clean duplicated items
              added = set()
              cleaned = []
              for inp, res in v:
                  str_key = measure_str_key(inp)
                  if str_key in added:
                      continue
                  added.add(str_key)
                  cleaned.append([inp, res])
  
              # write to file
              logger.info(
                  "Key: %s\tValid: %d\tDup: %d\t",
                  k,
                  len(cleaned),
                  len(v) - len(cleaned),
              )
              with open(args.i + f".{i:03d}.wkl", "w") as fout:
                  for inp, res in cleaned:
                      fout.write(encode(inp, res) + "\n")
      else:
          for i, (k, v) in enumerate(wkl_dict.items()):
              logger.info("Key: %s\tNum: %d", k, len(v))
              with open(args.i + f".{i:03d}.wkl", "w") as fout:
                  for inp, res in v:
                      fout.write(encode(inp, res) + "\n")
  
imports: import argparse
  import base64
  from io import TextIOBase
  import logging
  import pickle
  import json
  import time
  from typing import Union
  import os
  import itertools
  from collections import OrderedDict
  import numpy
  from ..None import build, lower
  from ..target import Target
  from ..contrib import popen_pool
  from ..None import __version__
  from .None import task
  from .task import ConfigEntity, ApplyHistoryBest
  from .measure import MeasureInput, MeasureResult
label_desc: Use image node_id 6 for calling a global function with example usage: split_workload(in_file, clean) without return types