class_docstr: Class to read the datasets in DocRED format
class_docstr_tok: ["Class","to","read","the","datasets","in","DocRED","format"]
docstr: <CURRENTLY NOT USED>
  Generated negative samples, i.e. the same document that is used for positive samples, but labeled with
  "no_relation" label and with entities, that are not connected with any relation, marked as such.
  
  Args:
       doc: list of positive sentences
       forbidden_entities: list of entities that participate in any of the relations (and, therefore, cannot be
          chosen for negative sample)
       num_neg_samples: number of negative samples that are to be generated out of this document
  Returns:
       a tuple with list of all doc tokens, entity information (positions & NER tags) and relation (=neg_label).
docstr_tok: ["<","CURRENTLY","NOT","USED",">","Generated","negative","samples",",","i.e",".","the","same","document","that","is","used","for","positive","samples",",","but","labeled","with","''","no_relation","''","label","and","with","entities",",","that","are","not","connected","with","any","relation",",","marked","as","such",".","Args",":","doc",":","list","of","positive","sentences","forbidden_entities",":","list","of","entities","that","participate","in","any","of","the","relations","(","and",",","therefore",",","can","not","be","chosen","for","negative","sample",")","num_neg_samples",":","number","of","negative","samples","that","are","to","be","generated","out","of","this","document","Returns",":","a","tuple","with","list","of","all","doc","tokens",",","entity","information","(","positions","&","NER","tags",")","and","relation","(","=neg_label",")","."]
code: def generate_additional_neg_samples(
      self, doc: List, forbidden_entities: List, num_neg_samples: int
  ):
      """
      <CURRENTLY NOT USED>
      Generated negative samples, i.e. the same document that is used for positive samples, but labeled with
      "no_relation" label and with entities, that are not connected with any relation, marked as such.
  
      Args:
           doc: list of positive sentences
           forbidden_entities: list of entities that participate in any of the relations (and, therefore, cannot be
              chosen for negative sample)
           num_neg_samples: number of negative samples that are to be generated out of this document
      Returns:
           a tuple with list of all doc tokens, entity information (positions & NER tags) and relation (=neg_label).
      """
      # ATTENTION! To make it work, please run the following command: python3 -m deeppavlov install ner_ontonotes_bert
  
      from deeppavlov import build_model, configs
  
      ner = build_model(
          configs.ner.ner_ontonotes_bert_mult, download=True
      )
      neg_data_samples = []
      analysed_sentences = ner(
          [" ".join(doc)]
      )  # returns [[[tokens]], [[ner tags]]]
  
      # select ids of tokens that were not part of any relation so far
      neg_entities_idx = random.sample(
          [
              ent_idx
              for ent_idx in range(len(analysed_sentences[0][0]))
              if analysed_sentences[0][0][ent_idx]
              not in forbidden_entities
          ],
          num_neg_samples * 2,
      )
  
      # the one hot encoding of the negative label
      neg_label_one_hot = self.label_to_one_hot(
          [self.rel2id[self.negative_label]]
      )
  
      for n_ent_1_idx, n_ent_2_idx in itertools.permutations(
          neg_entities_idx, 2
      ):
          # if already sufficient number of negative samples have been generated
          if len(neg_data_samples) == num_neg_samples:
              break
          neg_entity_1 = analysed_sentences[0][0][n_ent_1_idx]
          neg_entity_2 = analysed_sentences[0][0][n_ent_2_idx]
          neg_entity_1_tag = analysed_sentences[1][0][n_ent_1_idx]
          neg_entity_2_tag = analysed_sentences[1][0][n_ent_2_idx]
          neg_data_samples.append(
              (
                  doc,
                  [
                      [neg_entity_1],
                      [neg_entity_2],
                      neg_entity_1_tag,
                      neg_entity_2_tag,
                  ],
                  neg_label_one_hot,
              )
          )
          self.stat["NEG_REL"] += 1
  
      return neg_data_samples
  
imports: import itertools
  import json
  import os
  import random
  from logging import getLogger
  from pathlib import Path
  from typing import Dict, List, Tuple, Union
  import numpy
  import pandas
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.dataset_reader import DatasetReader
label_desc: Use image node_id 8 for calling the DocREDDatasetReader obj's underlying member method code with example usage: obj.generate_additional_neg_samples(doc, forbidden_entities, num_neg_samples) and returns: neg_data_samples