code: def test_named_entity_extractor_serde():
      extractor = NamedEntityExtractor(
          backend=NamedEntityExtractorBackend.HUGGING_FACE,
          model="dslim/bert-base-NER",
          device_id=-1,
      )
  
      serde_data = extractor.to_dict()
      new_extractor = NamedEntityExtractor.from_dict(serde_data)
  
      assert type(new_extractor._backend) == type(extractor._backend)
      assert (
          new_extractor._backend.model_name
          == extractor._backend.model_name
      )
      assert (
          new_extractor._backend.device_id
          == extractor._backend.device_id
      )
  
      with pytest.raises(
          DeserializationError, match=r"Couldn't deserialize"
      ):
          serde_data["init_parameters"].pop("backend")
          _ = NamedEntityExtractor.from_dict(serde_data)
  
imports: import pytest
  from haystack import ComponentError, DeserializationError
  from haystack.components.extractors import NamedEntityExtractor, NamedEntityExtractorBackend
label_desc: Use image node_id 2 for calling a global function with example usage: test_named_entity_extractor_serde() without return types