code: def test_entity_ruler_serialize_bytes(
      nlp, patterns, entity_ruler_factory
  ):
      ruler = EntityRuler(nlp, patterns=patterns)
      assert len(ruler) == len(patterns)
      assert len(ruler.labels) == 4
      ruler_bytes = ruler.to_bytes()
      new_ruler = EntityRuler(nlp)
      assert len(new_ruler) == 0
      assert len(new_ruler.labels) == 0
      new_ruler = new_ruler.from_bytes(ruler_bytes)
      assert len(new_ruler) == len(patterns)
      assert len(new_ruler.labels) == 4
      assert len(new_ruler.patterns) == len(ruler.patterns)
      for pattern in ruler.patterns:
          assert pattern in new_ruler.patterns
      assert sorted(new_ruler.labels) == sorted(ruler.labels)
  
imports: import pytest
  from thinc.api import NumpyOps, get_current_ops
  from spacy import registry
  from spacy.errors import MatchPatternError
  from spacy.lang.en import English
  from spacy.language import Language
  from spacy.pipeline import EntityRecognizer, EntityRuler, SpanRuler, merge_entities
  from spacy.pipeline.ner import DEFAULT_NER_MODEL
  from spacy.tests.util import make_tempdir
  from spacy.tokens import Doc, Span
label_desc: Use image node_id 19 for calling a global function with example usage: test_entity_ruler_serialize_bytes(nlp, patterns, entity_ruler_factory) without return types