class_docstr: Text Pair Regression Model for tasks such as Semantic Textual Similarity Benchmark.
  
  The model takes document embeddings and puts resulting text representation(s) into a linear layer to get the
  score. We provide two ways to embed the DataPairs: Either by embedding both DataPoints
  and concatenating the resulting vectors ("embed_separately=True") or by concatenating the DataPoints and embedding
  the resulting vector ("embed_separately=False").
class_docstr_tok: ["Text","Pair","Regression","Model","for","tasks","such","as","Semantic","Textual","Similarity","Benchmark",".","The","model","takes","document","embeddings","and","puts","resulting","text","representation","(","s",")","into","a","linear","layer","to","get","the","score",".","We","provide","two","ways","to","embed","the","DataPairs",":","Either","by","embedding","both","DataPoints","and","concatenating","the","resulting","vectors","(","``","embed_separately=True","''",")","or","by","concatenating","the","DataPoints","and","embedding","the","resulting","vector","(","``","embed_separately=False","''",")","."]
docstr: Initialize the Text Pair Regression Model.
  
  Args:
      label_type: name of the label
      embed_separately: if True, the sentence embeddings will be concatenated,
        if False both sentences will be combined and newly embedded.
      dropout: dropout
      locked_dropout: locked_dropout
      word_dropout:  word_dropout
      decoder: if provided, a that specific layer will be used as decoder,
        otherwise a linear layer with random parameters will be created.
      embeddings: embeddings used to embed each data point
docstr_tok: ["Initialize","the","Text","Pair","Regression","Model",".","Args",":","label_type",":","name","of","the","label","embed_separately",":","if","True",",","the","sentence","embeddings","will","be","concatenated",",","if","False","both","sentences","will","be","combined","and","newly","embedded",".","dropout",":","dropout","locked_dropout",":","locked_dropout","word_dropout",":","word_dropout","decoder",":","if","provided",",","a","that","specific","layer","will","be","used","as","decoder",",","otherwise","a","linear","layer","with","random","parameters","will","be","created",".","embeddings",":","embeddings","used","to","embed","each","data","point"]
code: def __init__(
      self,
      embeddings: flair.embeddings.DocumentEmbeddings,
      label_type: str,
      embed_separately: bool = False,
      dropout: float = 0.0,
      locked_dropout: float = 0.0,
      word_dropout: float = 0.0,
      decoder: Optional[torch.nn.Module] = None,
  ) -> None:
      """Initialize the Text Pair Regression Model.
  
      Args:
          label_type: name of the label
          embed_separately: if True, the sentence embeddings will be concatenated,
            if False both sentences will be combined and newly embedded.
          dropout: dropout
          locked_dropout: locked_dropout
          word_dropout:  word_dropout
          decoder: if provided, a that specific layer will be used as decoder,
            otherwise a linear layer with random parameters will be created.
          embeddings: embeddings used to embed each data point
      """
      super().__init__()
  
      self.embeddings: flair.embeddings.DocumentEmbeddings = embeddings
      self.label_name = label_type
      self.embed_separately = embed_separately
  
      if not self.embed_separately:
          # set separator to concatenate two sentences
          self.sep = " "
          if isinstance(
              self.embeddings,
              flair.embeddings.document.TransformerDocumentEmbeddings,
          ):
              if self.embeddings.tokenizer.sep_token:
                  self.sep = (
                      " "
                      + str(self.embeddings.tokenizer.sep_token)
                      + " "
                  )
              else:
                  self.sep = " [SEP] "
  
      self.decoder: torch.nn.Module
      if decoder is None:
          self.decoder = nn.Linear(
              2 * embeddings.embedding_length
              if embed_separately
              else embeddings.embedding_length,
              1,
          )
          nn.init.xavier_uniform_(self.decoder.weight)
  
      else:
          self.decoder = decoder
  
      # init dropouts
      self.dropout: torch.nn.Dropout = torch.nn.Dropout(dropout)
      self.locked_dropout = flair.nn.LockedDropout(locked_dropout)
      self.word_dropout = flair.nn.WordDropout(word_dropout)
  
      self.loss_function = nn.MSELoss(reduction="sum")
  
      # auto-spawn on GPU if available
      self.to(flair.device)
  
imports: import typing
  from pathlib import Path
  from typing import Any, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.utils.data.dataset import Dataset
  from tqdm import tqdm
  import flair.embeddings
  import flair.nn
  from flair.data import Corpus, Dictionary, Sentence, TextPair, _iter_dataset
  from flair.datasets import DataLoader, FlairDatapointDataset
  from flair.nn.model import ReduceTransformerVocabMixin
  from flair.training_utils import MetricRegression, Result, store_embeddings
label_desc: Use image node_id 1 to create a new TextPairRegressor object from inherited base classes: flair.nn.Model, ReduceTransformerVocabMixin with example: obj = TextPairRegressor(embeddings, label_type, embed_separately, dropout, locked_dropout, word_dropout, decoder)