docstr: Construct a Named Entity extractor component.
  
  :param backend:
      Backend to use for NER.
  :param model:
      Name of the model or a path to the model on
      the local disk.
  
      Dependent on the backend.
  :param pipeline_kwargs:
      Keyword arguments passed to the pipeline. The
      pipeline can override these arguments.
  
      Dependent on the backend.
  :param device_id:
      Identifier of the device on which the backend
      is executed.
  
      To execute on the CPU, pass a value of `-1`.
      To execute on the GPU, pass the GPU identifier.
docstr_tok: ["Construct","a","Named","Entity","extractor","component",".",":","param","backend",":","Backend","to","use","for","NER",".",":","param","model",":","Name","of","the","model","or","a","path","to","the","model","on","the","local","disk",".","Dependent","on","the","backend",".",":","param","pipeline_kwargs",":","Keyword","arguments","passed","to","the","pipeline",".","The","pipeline","can","override","these","arguments",".","Dependent","on","the","backend",".",":","param","device_id",":","Identifier","of","the","device","on","which","the","backend","is","executed",".","To","execute","on","the","CPU",",","pass","a","value","of","`","-1","`",".","To","execute","on","the","GPU",",","pass","the","GPU","identifier","."]
code: def __init__(
      self,
      *,
      backend: Union[str, NamedEntityExtractorBackend],
      model: str,
      pipeline_kwargs: Optional[Dict[str, Any]] = None,
      device_id: int = -1,
  ) -> None:
      """
      Construct a Named Entity extractor component.
  
      :param backend:
          Backend to use for NER.
      :param model:
          Name of the model or a path to the model on
          the local disk.
  
          Dependent on the backend.
      :param pipeline_kwargs:
          Keyword arguments passed to the pipeline. The
          pipeline can override these arguments.
  
          Dependent on the backend.
      :param device_id:
          Identifier of the device on which the backend
          is executed.
  
          To execute on the CPU, pass a value of `-1`.
          To execute on the GPU, pass the GPU identifier.
      """
  
      if isinstance(backend, str):
          backend = NamedEntityExtractorBackend(backend)
  
      self._backend: _NerBackend
      if backend == NamedEntityExtractorBackend.HUGGING_FACE:
          self._backend = _HfBackend(
              model_name_or_path=model,
              device_id=device_id,
              pipeline_kwargs=pipeline_kwargs,
          )
      elif backend == NamedEntityExtractorBackend.SPACY:
          self._backend = _SpacyBackend(
              model_name_or_path=model,
              device_id=device_id,
              pipeline_kwargs=pipeline_kwargs,
          )
      else:
          raise ComponentError(
              f"Unknown NER backend '{type(backend).__name__}' for extractor"
          )
  
imports: from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from dataclasses import dataclass
  from enum import Enum, EnumMeta
  from typing import Any, Dict, List, Optional, Union
  from ...None import ComponentError, DeserializationError, Document, component, default_from_dict, default_to_dict
  from ...lazy_imports import LazyImport
label_desc: Use image node_id 1 to create a new NamedEntityExtractor object  with example: obj = NamedEntityExtractor()