code: def test_sense2vec_to_from_bytes():
      s2v = Sense2Vec(shape=(2, 4))
      test_vector1 = numpy.asarray([1, 2, 3, 4], dtype=numpy.float32)
      test_vector2 = numpy.asarray([5, 6, 7, 8], dtype=numpy.float32)
      s2v.add("test1", test_vector1, 123)
      s2v.add("test2", test_vector2, 456)
      s2v_bytes = s2v.to_bytes()
      new_s2v = Sense2Vec().from_bytes(s2v_bytes)
      assert len(new_s2v) == 2
      assert new_s2v.vectors.shape == (2, 4)
      assert "test1" in new_s2v
      assert "test2" in new_s2v
      assert new_s2v.get_freq("test1") == 123
      assert new_s2v.get_freq("test2") == 456
      assert numpy.array_equal(new_s2v["test1"], test_vector1)
      assert numpy.array_equal(new_s2v["test2"], test_vector2)
      assert s2v_bytes == new_s2v.to_bytes()
      s2v_bytes2 = s2v.to_bytes(exclude=["strings"])
      new_s2v2 = Sense2Vec().from_bytes(s2v_bytes2)
      assert len(new_s2v2.strings) == 0
      assert "test1" in new_s2v2
      assert s2v.strings["test1"] in new_s2v2
      with pytest.raises(KeyError):  # can't resolve hash
          new_s2v2.strings[s2v.strings["test2"]]
  
file_path: sense2vec/sense2vec/tests/test_sense2vec.py
imports: import pytest
  import numpy
  from sense2vec import Sense2Vec, registry
label_desc: Use image node_id 7 for calling a global function with example usage: test_sense2vec_to_from_bytes() without return types