class_docstr: Class providing an artificial backend, that reads data into memory.
class_docstr_tok: ["Class","providing","an","artificial","backend",",","that","reads","data","into","memory","."]
docstr: Get subjects complementary to triples (?,p,o).
  
  For a given triple retrieve all subjects coming from triples with same objects and predicates.
  
  Parameters
  ----------
  triples : list or array
       List or array of arrays with 3 elements (subject, predicate, object).
  
  Returns
  -------
  subjects : list
       Subjects present in the input triples.
docstr_tok: ["Get","subjects","complementary","to","triples","(","?",",","p",",","o",")",".","For","a","given","triple","retrieve","all","subjects","coming","from","triples","with","same","objects","and","predicates",".","Parameters","--","--","--","--","--","triples",":","list","or","array","List","or","array","of","arrays","with","3","elements","(","subject",",","predicate",",","object",")",".","Returns","--","--","--","-","subjects",":","list","Subjects","present","in","the","input","triples","."]
code: def _get_complementary_subjects(self, triples, use_filter=False):
      """Get subjects complementary to triples (?,p,o).
  
      For a given triple retrieve all subjects coming from triples with same objects and predicates.
  
      Parameters
      ----------
      triples : list or array
           List or array of arrays with 3 elements (subject, predicate, object).
  
      Returns
      -------
      subjects : list
           Subjects present in the input triples.
      """
  
      logger.debug("Getting complementary subjects")
  
      if self.parent is not None:
          logger.debug(
              "Parent is set, WARNING: The triples returned are coming with parent indexing."
          )
  
          logger.debug("Recover original indexes.")
          triples_original_index = self.mapper.get_indexes(
              triples, order="ind2raw"
          )
  
          #            with shelve.open(self.mapper.reversed_entities_dict) as ents:
          #                with shelve.open(self.mapper.reversed_relations_dict) as rels:
          #                    triples_original_index = np.array([(ents[str(xx[0])],
          #                                                        rels[str(xx[1])],
          #                                                        ents[str(xx[2])]) for xx in triples],
          #                                                      dtype=np.int32)
          logger.debug("Query parent for data.")
          subjects = self.parent.get_complementary_subjects(
              triples_original_index
          )
          logger.debug(
              "What to do with this new indexes? Evaluation should happen in the \
              original space, shouldn't it? I'm assuming it does so returning in parent indexing."
          )
          return subjects
      elif self.use_filter is False or self.use_filter is None:
          self.use_filter = {"train-org": self.data}
  
      filtered = []
      for filter_name, filter_source in self.use_filter.items():
          source = self.get_source(filter_source, filter_name)
  
          tmp_filter = []
          for triple in triples:
              tmp = source[source[:, 2] == triple[2]]
              tmp_filter.append(
                  list(set(tmp[tmp[:, 1] == triple[1]][:, 0]))
              )
          filtered.append(tmp_filter)
      # Unpack data into one list per triple no matter what filter it comes
      # from
      unpacked = list(zip(*filtered))
      subjects = []
      for k in unpacked:
          lst = [j for i in k for j in i]
          subjects.append(np.array(lst, dtype=np.int32))
  
      return subjects
  
imports: import logging
  import tempfile
  import uuid
  from datetime import datetime
  import numpy
  import pandas
  import tensorflow
  from .data_indexer import DataIndexer
  from .source_identifier import DataSourceIdentifier
label_desc: Use image node_id 10 for calling the NoBackend obj's underlying member method code with example usage: obj._get_complementary_subjects(triples, use_filter) and returns: subjects, subjects