code: def test_component_to_from_bytes(doc):
      s2v = Sense2VecComponent(doc.vocab, shape=(1, 4))
      s2v.first_run = False
      vector = numpy.asarray([4, 2, 2, 2], dtype=numpy.float32)
      s2v.s2v.add("world|NOUN", vector)
      assert "world|NOUN" in s2v.s2v
      assert "world|GPE" not in s2v.s2v
      doc = s2v(doc)
      assert doc[0]._.in_s2v is False
      assert doc[1]._.in_s2v is True
      s2v_bytes = s2v.to_bytes()
      new_s2v = Sense2VecComponent(doc.vocab).from_bytes(s2v_bytes)
      new_s2v.first_run = False
      assert "world|NOUN" in new_s2v.s2v
      assert numpy.array_equal(new_s2v.s2v["world|NOUN"], vector)
      assert "world|GPE" not in new_s2v.s2v
      new_s2v.s2v.vectors.resize((2, 4))
      new_s2v.s2v.add("hello|INTJ", vector)
      assert doc[0]._.in_s2v is False
      new_doc = new_s2v(doc)
      assert new_doc[0]._.in_s2v 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 6 for calling a global function with example usage: test_component_to_from_bytes(doc) without return types