code: def extract_entities(
      sentence: str,
      pos: Tuple[str] = ("PROPN", "NOUN"),
      use_named_entities: bool = True,
      use_noun_chunks: bool = True,
  ) -> List[str]:
      """
      Given a sentence, extract the entities from the sentence.
  
      :param sentence:
          provided sentence
      :param pos:
          parts of speech to look at
      :param use_named_entities:
          whether to include named entities
      :param use_noun_chunks:
          whether to include noun chunks.
  
      :return entities:
          return list of entities.
      """
      global nlp
      if nlp is None:
          logging.info("Loading spacy once")
          try:
              assert spacy is not None
              nlp = spacy.load("en_core_web_sm")
          except Exception:
              raise RuntimeError(
                  "Please download: python -m spacy download en_core_web_sm"
              )
      doc = nlp(sentence)
      results = []
      if pos:
          for token in doc:
              if token.pos_ in pos:
                  results.append(token)
      if use_named_entities:
          for ent in doc.ents:
              results.append(ent)
      if use_noun_chunks:
          for chunk in doc.noun_chunks:
              if chunk.text.lower() not in STOP_WORDS:
                  results.append(chunk)
      results = list(set([r.text for r in results]))
      return results
  
file_path: ParlAI/projects/seeker/utils.py
imports: from collections import Counter
  from enum import Enum
  import torch
  from typing import Callable, List, Tuple
  from parlai.core.torch_agent import Batch
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
  import parlai.utils.logging
label_desc: Use image node_id 4 for calling a global function with example usage: extract_entities(sentence, pos, use_named_entities, use_noun_chunks) and returns: results