code: def test_span_ruler_init_patterns(patterns):
      # initialize with patterns
      nlp = spacy.blank("xx")
      ruler = nlp.add_pipe("span_ruler")
      assert len(ruler.labels) == 0
      ruler.initialize(lambda: [], patterns=patterns)
      assert len(ruler.labels) == 4
      doc = nlp("hello world bye bye")
      assert doc.spans["ruler"][0].label_ == "HELLO"
      assert doc.spans["ruler"][1].label_ == "BYE"
      nlp.remove_pipe("span_ruler")
      # initialize with patterns from misc registry
      nlp.config["initialize"]["components"]["span_ruler"] = {
          "patterns": {"@misc": "span_ruler_patterns"}
      }
      ruler = nlp.add_pipe("span_ruler")
      assert len(ruler.labels) == 0
      nlp.initialize()
      assert len(ruler.labels) == 4
      doc = nlp("hello world bye bye")
      assert doc.spans["ruler"][0].label_ == "HELLO"
      assert doc.spans["ruler"][1].label_ == "BYE"
  
imports: import pytest
  from thinc.api import NumpyOps, get_current_ops
  import spacy
  from spacy import registry
  from spacy.errors import MatchPatternError
  from spacy.tests.util import make_tempdir
  from spacy.tokens import Span
  from spacy.training import Example
label_desc: Use image node_id 8 for calling a global function with example usage: test_span_ruler_init_patterns(patterns) without return types