code: def test_component_lemmatize(doc):
      def lemmatize(doc, lookups):
          for token in doc:
              token.lemma_ = lookups.get(token.text, token.text)
          return doc
  
      s2v = Sense2VecComponent(doc.vocab, shape=(4, 4), lemmatize=True)
      s2v.first_run = False
      vector = numpy.asarray([4, 2, 2, 2], dtype=numpy.float32)
      s2v.s2v.add("hello|INTJ", vector)
      s2v.s2v.add("world|NOUN", vector)
      s2v.s2v.add("wrld|NOUN", vector)
      doc = lemmatize(doc, {"world": "wrld"})
      doc = s2v(doc)
      assert doc[0]._.s2v_key == "hello|INTJ"
      assert doc[1].lemma_ == "wrld"
      assert doc[1]._.s2v_key == "wrld|NOUN"
      doc = lemmatize(doc, {"hello": "hll"})
      assert doc[0].lemma_ == "hll"
      assert doc[0]._.s2v_key == "hello|INTJ"
      s2v.s2v.add("hll|INTJ", vector)
      assert doc[0]._.s2v_key == "hll|INTJ"
      new_s2v = Sense2VecComponent().from_bytes(s2v.to_bytes())
      assert new_s2v.s2v.cfg["lemmatize"] is True
  
file_path: sense2vec/sense2vec/tests/test_component.py
imports: import pytest
  import numpy
  import spacy
  from spacy.vocab import Vocab
  from spacy.tokens import Doc, Span
  from sense2vec import Sense2VecComponent
  from pathlib import Path
label_desc: Use image node_id 5 for calling a global function with example usage: test_component_lemmatize(doc) and returns: doc