code: def _write_aspect_lex(
      parsed_data: Union[str, PathLike],
      generated_aspect_lex: dict,
      out_dir: Path,
  ):
      parsed_docs = _load_parsed_docs_from_dir(parsed_data)
      aspect_dict = {}
      max_examples = 20
      label = "AS"
      for doc in parsed_docs.values():
          for sent_text, _ in doc.sent_iter():
              for term, lemma in generated_aspect_lex.items():
                  if term in sent_text.lower():
                      _find_aspect_in_sentence(
                          term,
                          lemma,
                          sent_text,
                          aspect_dict,
                          label,
                          max_examples,
                          False,
                      )
                  if lemma != "" and lemma in sent_text.lower():
                      _find_aspect_in_sentence(
                          term,
                          lemma,
                          sent_text,
                          aspect_dict,
                          label,
                          max_examples,
                          True,
                      )
  
      # write aspect lex to file
      header_row = ["Term", "Alias1", "Alias2", "Alias3"]
      for k in range(1, max_examples + 1):
          header_row.append("Example" + str(k))
      aspect_table = [header_row]
  
      for [term, lemma], sentences in aspect_dict.items():
          term_row = [term, lemma, "", ""]
          for sent in sentences:
              term_row.append(sent)
          aspect_table.append(term_row)
  
      out_dir.mkdir(parents=True, exist_ok=True)
      out_file_path = out_dir / "generated_aspect_lex.csv"
      _write_table(aspect_table, out_file_path)
      print("Aspect lexicon written to {}".format(out_file_path))
  
imports: import csv
  import json
  import sys
  from os import walk, path, makedirs, PathLike, listdir
  from os.path import join, isfile, isdir
  from pathlib import Path
  from typing import Union
  from tqdm import tqdm
  import numpy
  from nlp_architect.common.core_nlp_doc import CoreNLPDoc
  from nlp_architect.models.absa import INFERENCE_LEXICONS
  from nlp_architect.models.absa.inference.data_types import LexiconElement, Polarity
  from nlp_architect.models.absa.train.data_types import OpinionTerm
  from nlp_architect.pipelines.spacy_bist import SpacyBISTParser
  from nlp_architect.utils.io import download_unlicensed_file, line_count
  from types import GeneratorType
label_desc: Use image node_id 20 for calling a global function with example usage: _write_aspect_lex(parsed_data, generated_aspect_lex, out_dir) without return types