docstr: Initializes a RelationClassifier.
  
  Args:
      embeddings: embeddings used to embed each data point
      label_type: name of the label
      entity_label_type: name of the labels used to represent entities
      entity_pair_filters: if provided, only classify pairs that apply the filter
      pooling_operation: either "first" or "first_last" how the embeddings of the entities
        should be used to create relation embeddings
      train_on_gold_pairs_only: if True, relations with "O" (no relation) label will be ignored in training.
      **classifierargs: The arguments propagated to :meth:`flair.nn.DefaultClassifier.__init__`
docstr_tok: ["Initializes","a","RelationClassifier",".","Args",":","embeddings",":","embeddings","used","to","embed","each","data","point","label_type",":","name","of","the","label","entity_label_type",":","name","of","the","labels","used","to","represent","entities","entity_pair_filters",":","if","provided",",","only","classify","pairs","that","apply","the","filter","pooling_operation",":","either","``","first","''","or","``","first_last","''","how","the","embeddings","of","the","entities","should","be","used","to","create","relation","embeddings","train_on_gold_pairs_only",":","if","True",",","relations","with","``","O","''","(","no","relation",")","label","will","be","ignored","in","training",".","*","*","classifierargs",":","The","arguments","propagated","to",":","meth",":","`","flair.nn.DefaultClassifier.__init__","`"]
code: def __init__(
      self,
      embeddings: flair.embeddings.TokenEmbeddings,
      label_type: str,
      entity_label_type: str,
      entity_pair_filters: Optional[List[Tuple[str, str]]] = None,
      pooling_operation: str = "first_last",
      train_on_gold_pairs_only: bool = False,
      **classifierargs,
  ) -> None:
      """Initializes a RelationClassifier.
  
      Args:
          embeddings: embeddings used to embed each data point
          label_type: name of the label
          entity_label_type: name of the labels used to represent entities
          entity_pair_filters: if provided, only classify pairs that apply the filter
          pooling_operation: either "first" or "first_last" how the embeddings of the entities
            should be used to create relation embeddings
          train_on_gold_pairs_only: if True, relations with "O" (no relation) label will be ignored in training.
          **classifierargs: The arguments propagated to :meth:`flair.nn.DefaultClassifier.__init__`
      """
      # pooling operation to get embeddings for entites
      self.pooling_operation = pooling_operation
      relation_representation_length = 2 * embeddings.embedding_length
      if self.pooling_operation == "first_last":
          relation_representation_length *= 2
      super().__init__(
          embeddings=embeddings,
          final_embedding_size=relation_representation_length,
          **classifierargs,
      )
  
      # set embeddings
      self.embeddings: flair.embeddings.TokenEmbeddings = embeddings
  
      # set relation and entity label types
      self._label_type = label_type
      self.entity_label_type = entity_label_type
      self.train_on_gold_pairs_only = train_on_gold_pairs_only
  
      # whether to use gold entity pairs, and whether to filter entity pairs by type
      if entity_pair_filters is not None:
          self.entity_pair_filters: Optional[
              Set[Tuple[str, str]]
          ] = set(entity_pair_filters)
      else:
          self.entity_pair_filters = None
  
      self.to(flair.device)
  
file_path: flair/flair/models/relation_extractor_model.py
imports: import logging
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  import torch
  import flair.embeddings
  import flair.nn
  from flair.data import Relation, Sentence
  from flair.file_utils import cached_path
label_desc: Use image node_id 1 to create a new RelationExtractor object from inherited base classes: flair.nn.DefaultClassifier with example: obj = RelationExtractor(embeddings, label_type, entity_label_type, entity_pair_filters, pooling_operation, train_on_gold_pairs_only)