code: def lexical_analysis(models, dataset, corpora, charts):
      models = models + ["Target"]
      corpora = corpora + [dataset.target_text]
  
      max_ngram = 4
      src_sents = [word_tokenize(s) for s in dataset.source_text]
      src_ngrams = [
          [
              set([" ".join(n) for n in ngrams(sent, i)])
              for sent in src_sents
          ]
          for i in range(1, max_ngram + 1)
      ]
  
      features = [
          "Length",
          "NRC_Valence",
          "Concreteness",
          "Log_Lexical_Frequency",
          "Ngram Overlap",
      ]
      databases = load_lexical_database(features)
      lemmatizer = WordNetLemmatizer()
      model_features = []
      for texts in corpora:
          feas = []
          sents_tokens = [word_tokenize(t) for t in texts]
          sents_tags = [
              [
                  tag[0].lower()
                  if tag[0] in ["V", "N", "R"]
                  else ("a" if tag[0] == "J" else "")
                  for _, tag in pos_tag(tokens)
              ]
              for tokens in sents_tokens
          ]
          sents_lemmas = [
              [
                  lemmatizer.lemmatize(token, tag)
                  if tag != ""
                  else token
                  for token, tag in zip(tokens, tags)
              ]
              for tokens, tags in zip(sents_tokens, sents_tags)
          ]
          for feature in features:
              if feature == "Length":
                  feas.append(
                      [[len(tokens) for tokens in sents_tokens]]
                  )
              elif feature == "Ngram Overlap":
                  fea = []
                  for i in range(1, max_ngram + 1):
                      overlaps = []
                      for src_ngram, tgt_tokens in zip(
                          src_ngrams[i - 1], sents_tokens
                      ):
                          tgt_ngram = [
                              " ".join(n) for n in ngrams(tgt_tokens, i)
                          ]
                          overlap = (
                              sum([n in src_ngram for n in tgt_ngram])
                              / len(tgt_ngram)
                              if len(tgt_ngram)
                              else 0
                          )
                          overlaps.append(overlap)
                      fea.append(overlaps)
                  feas.append(fea)
              elif feature in sentspace_database:
                  fea = []
                  feature_dict = databases[feature]
                  for tokens, lemmas in zip(sents_tokens, sents_lemmas):
                      f = []
                      for token, lemma in zip(tokens, lemmas):
                          if token in feature_dict:
                              f.append(feature_dict[token])
                          elif lemma in feature_dict:
                              f.append(feature_dict[lemma])
                          else:
                              f.append(0)
                      fea.append(np.mean(f))
                  feas.append([fea])
          model_features.append(feas)
  
      grid = Grid(
          init_opts=opts.InitOpts(
              theme=ThemeType.SHINE, width="900px", height="400px"
          )
      )
      grid_num = 0
      for i, feature in enumerate(features):
          if feature != "Ngram Overlap":
              chart = Boxplot(
                  init_opts=opts.InitOpts(theme=ThemeType.SHINE)
              )
              chart.add_xaxis([feature])
          else:
              chart = Boxplot(
                  init_opts=opts.InitOpts(
                      theme=ThemeType.SHINE,
                      width="900px",
                      height="400px",
                  )
              )
              chart.add_xaxis([str(i) for i in range(1, max_ngram + 1)])
          for model, features in zip(models, model_features):
              chart.add_yaxis(
                  model,
                  chart.prepare_data(features[i]),
                  tooltip_opts=opts.TooltipOpts(
                      textstyle_opts=opts.TextStyleOpts(
                          color="white", **default_text_style
                      )
                  ),
              )
          title_name = (
              "Lexcial Features"
              if i == 0
              else (feature if feature == "Ngram Overlap" else "")
          )
          chart.set_global_opts(
              title_opts=opts.TitleOpts(
                  title=title_name,
                  title_textstyle_opts=opts.TextStyleOpts(
                      **default_text_style
                  ),
              ),
              legend_opts=opts.LegendOpts(
                  pos_top=25,
                  textstyle_opts=opts.TextStyleOpts(
                      **default_text_style
                  ),
              ),
              xaxis_opts=opts.AxisOpts(
                  name="Ngram" if feature == "Ngram Overlap" else "",
                  axislabel_opts=opts.LabelOpts(**default_text_style),
                  name_textstyle_opts=opts.TextStyleOpts(
                      **default_text_style
                  ),
              ),
              yaxis_opts=opts.AxisOpts(
                  axislabel_opts=opts.LabelOpts(**default_text_style)
              ),
          )
          if feature != "Ngram Overlap":
              left = round((grid_num / (len(features) - 1)) * 100, 2)
              right = 100 - 100 / (len(features) - 1) - left
              left = str(left + 4) + "%"
              right = str(right) + "%"
              grid_num += 1
              grid.add(
                  chart,
                  grid_opts=opts.GridOpts(
                      pos_left=left, pos_right=right
                  ),
              )
          else:
              charts.add(chart)
      charts.add(grid)
  
imports: import argparse
  import pickle
  import numpy
  import scipy
  from collections import Counter
  from nltk.util import ngrams
  from nltk.tokenize import word_tokenize
  from nltk.stem import WordNetLemmatizer
  from nltk import pos_tag
  from nltk.corpus import stopwords
  from pyecharts import options
  from pyecharts.charts import Page, Grid, Boxplot, WordCloud
  from pyecharts.globals import ThemeType, SymbolType
  from pyecharts.components import Table
  from pyecharts.options import ComponentTitleOpts
  from textbox.config.configurator import Config
  from textbox.evaluator import BaseEvaluator
  from textbox.data.utils import AbstractDataset
label_desc: Use image node_id 3 for calling a global function with example usage: lexical_analysis(models, dataset, corpora, charts) without return types