class_docstr: Partitioning strategy that splits vertices into equal sized buckets of random entities from the graph.
  
  Example
  -------
  >>> from ampligraph.datasets imoprt load_fb15k_237
  >>> from ampligraph.datasets import GraphDataLoader
  >>> from ampligraph.datasets.sqlite_adapter import SQLiteAdapter
  >>> from ampligraph.datasets.graph_partitioner import RandomVerticesGraphPartitioner
  >>> from ampligraph.latent_features import ScoringBasedEmbeddingModel
  >>> dataset = load_fb15k_237()
  >>> dataset_loader = GraphDataLoader(dataset['train'],
  >>>                                  backend=SQLiteAdapter, # type of backend to use
  >>>                                  batch_size=2,          # batch size to use while iterating over this dataset
  >>>                                  dataset_type='train',  # dataset type
  >>>                                  use_filter=False,      # whether to use filter or not
  >>>                                  use_indexer=True)      # indicates that the data needs to be mapped to index
  >>> partitioner = RandomVerticesGraphPartitioner(dataset_loader, k=2)
  >>> # create and compile a model as usual
  >>> partitioned_model = ScoringBasedEmbeddingModel(eta=2,
  >>>                                                k=50,
  >>>                                                scoring_type='DistMult')
  >>>
  >>> partitioned_model.compile(optimizer='adam', loss='multiclass_nll')
  >>>
  >>> partitioned_model.fit(partitioner,            # pass the partitioner object as input to the fit function this will generate data for the model during training
  >>>                       epochs=10)              # number of epochs
  
  Example
  -------
  >>> import numpy as np
  >>> from ampligraph.datasets.graph_partitioner import GraphDataLoader, RandomVerticesGraphPartitioner
  >>> d = np.array([[1,1,2], [1,1,3],[1,1,4],[5,1,3],[5,1,2],[6,1,3],[6,1,2],[6,1,4],[6,1,7]])
  >>> data = GraphDataLoader(d, batch_size=1, dataset_type="test")
  >>> partitioner = RandomVerticesGraphPartitioner(data, k=2)
  >>> for i, partition in enumerate(partitioner):
  >>>    print("partition ", i)
  >>>    for batch in partition:
  >>>        print(batch)
class_docstr_tok: ["Partitioning","strategy","that","splits","vertices","into","equal","sized","buckets","of","random","entities","from","the","graph",".","Example","--","--","--","-",">",">",">","from","ampligraph.datasets","imoprt","load_fb15k_237",">",">",">","from","ampligraph.datasets","import","GraphDataLoader",">",">",">","from","ampligraph.datasets.sqlite_adapter","import","SQLiteAdapter",">",">",">","from","ampligraph.datasets.graph_partitioner","import","RandomVerticesGraphPartitioner",">",">",">","from","ampligraph.latent_features","import","ScoringBasedEmbeddingModel",">",">",">","dataset","=","load_fb15k_237","(",")",">",">",">","dataset_loader","=","GraphDataLoader","(","dataset","[","'train","'","]",",",">",">",">","backend=SQLiteAdapter",",","#","type","of","backend","to","use",">",">",">","batch_size=2",",","#","batch","size","to","use","while","iterating","over","this","dataset",">",">",">","dataset_type='train","'",",","#","dataset","type",">",">",">","use_filter=False",",","#","whether","to","use","filter","or","not",">",">",">","use_indexer=True",")","#","indicates","that","the","data","needs","to","be","mapped","to","index",">",">",">","partitioner","=","RandomVerticesGraphPartitioner","(","dataset_loader",",","k=2",")",">",">",">","#","create","and","compile","a","model","as","usual",">",">",">","partitioned_model","=","ScoringBasedEmbeddingModel","(","eta=2",",",">",">",">","k=50",",",">",">",">","scoring_type='DistMult","'",")",">",">",">",">",">",">","partitioned_model.compile","(","optimizer='adam","'",",","loss='multiclass_nll","'",")",">",">",">",">",">",">","partitioned_model.fit","(","partitioner",",","#","pass","the","partitioner","object","as","input","to","the","fit","function","this","will","generate","data","for","the","model","during","training",">",">",">","epochs=10",")","#","number","of","epochs","Example","--","--","--","-",">",">",">","import","numpy","as","np",">",">",">","from","ampligraph.datasets.graph_partitioner","import","GraphDataLoader",",","RandomVerticesGraphPartitioner",">",">",">","d","=","np.array","(","[","[","1,1,2","]",",","[","1,1,3","]",",","[","1,1,4","]",",","[","5,1,3","]",",","[","5,1,2","]",",","[","6,1,3","]",",","[","6,1,2","]",",","[","6,1,4","]",",","[","6,1,7","]","]",")",">",">",">","data","=","GraphDataLoader","(","d",",","batch_size=1",",","dataset_type=","''","test","''",")",">",">",">","partitioner","=","RandomVerticesGraphPartitioner","(","data",",","k=2",")",">",">",">","for","i",",","partition","in","enumerate","(","partitioner",")",":",">",">",">","print","(","``","partition","``",",","i",")",">",">",">","for","batch","in","partition",":",">",">",">","print","(","batch",")"]
docstr: Split data into `k` equal size partitions by randomly drawing subset of vertices
  of partition size and retrieving triples associated with these vertices.
docstr_tok: ["Split","data","into","`","k","`","equal","size","partitions","by","randomly","drawing","subset","of","vertices","of","partition","size","and","retrieving","triples","associated","with","these","vertices","."]
code: def _split(self, seed=None, batch_size=1, **kwargs):
      """Split data into `k` equal size partitions by randomly drawing subset of vertices
      of partition size and retrieving triples associated with these vertices.
  
      """
      timestamp = datetime.now().strftime("%d-%m-%Y_%I-%M-%S_%p")
      self.ents_size = self._data.backend.mapper.get_entities_count()
      # logger.debug(self.ents_size)
      # logger.debug(backend.mapper.max_ents_index)
      self.partition_size = int(np.ceil(self.ents_size / self._k))
      # logger.debug(self.partition_size)
      self.buckets_generator = (
          self._data.backend.mapper.get_entities_in_batches(
              batch_size=self.partition_size, random=True, seed=seed
          )
      )
  
      for partition_nb, partition in enumerate(self.buckets_generator):
          # logger.debug(partition)
          tmp = np.array(
              self._data.backend._get_triples(entities=partition)
          )
          # tmp_subj = np.array(self._data.backend._get_triples(subjects=partition))
          # tmp_obj = np.array(self._data.backend._get_triples(objects=partition))
          # tmp = np.unique(np.concatenate([tmp_subj, tmp_obj], axis=0), axis=0)
  
          if tmp.size != 0:
              triples = tmp[:, :3].astype(np.int32)
              # logger.debug("unique triples: {}".format(triples))
              fname = "partition_{}_{}.csv".format(
                  partition_nb, timestamp
              )
              fname = os.path.join(self.root_dir, fname)
              self.files.append(fname)
              np.savetxt(fname, triples, delimiter="\t", fmt="%d")
              # special case of GraphDataLoader to create partition datasets:
              # with remapped indexes (0, size_of_partition),
              # persisted, with partition number to look up remappings
              partition_loader = GraphDataLoader(
                  fname,
                  use_indexer=False,
                  batch_size=batch_size,
                  remap=True,
                  parent=self._data,
                  name="partition_{}".format(partition_nb),
              )
              self.partitions.append(partition_loader)
          else:
              logger.debug("Partition has no triples, skipping!")
  
imports: import logging
  import os
  import shelve
  import tempfile
  from abc import ABC
  from datetime import datetime
  import numpy
  from ampligraph.utils.profiling import timing_and_memory
  from .graph_data_loader import GraphDataLoader
label_desc: Use image node_id 2 for calling the RandomVerticesGraphPartitioner obj's underlying member method code with example usage: obj._split(seed, batch_size) without return types