class_docstr: Manages the partitioning related controls.
  
  Handles data generation and informs the model about changes in partition.
class_docstr_tok: ["Manages","the","partitioning","related","controls",".","Handles","data","generation","and","informs","the","model","about","changes","in","partition","."]
docstr: Gets a new partition to train and loads all the parameters of the partition.
  
  Parameters
  ----------
  graph_data_loader : GraphDataLoader
      Data loader of the next partition that will be trained.
  partition_number: int
      Partition number of the next partition will be trained.
code: def _change_partition(self, graph_data_loader, partition_number):
      """Gets a new partition to train and loads all the parameters of the partition.
  
      Parameters
      ----------
      graph_data_loader : GraphDataLoader
          Data loader of the next partition that will be trained.
      partition_number: int
          Partition number of the next partition will be trained.
      """
      # from the graph data loader of the current partition get the original
      # entity ids
      ent_count_in_partition = (
          graph_data_loader.backend.mapper.get_entities_count()
      )
      self.ent_original_ids = (
          graph_data_loader.backend.mapper.get_indexes(
              np.arange(ent_count_in_partition),
              type_of="e",
              order="ind2raw",
          )
      )
      """
          with shelve.open(graph_data_loader.backend.mapper.entities_dict) as partition:
              # get the partition keys(remapped 0 - partition size)
              partition_keys = sorted([int(key) for key in partition.keys()])
              # get the original key's i.e. original entity ids (between 0 and total entities in dataset)
              self.ent_original_ids = [partition[str(key)] for key in partition_keys]
          """
      with shelve.open(self.ent_map_fname) as partition:
          self.all_ent_embs = []
          self.all_ent_opt_params = []
          for key in self.ent_original_ids:
              self.all_ent_opt_params.append(partition[key][0])
              self.all_ent_embs.append(partition[key][1])
          self.all_ent_embs = np.concatenate(self.all_ent_embs, 0)
          self.all_ent_opt_params = np.concatenate(
              self.all_ent_opt_params, 0
          )
  
      rel_count_in_partition = (
          graph_data_loader.backend.mapper.get_relations_count()
      )
      self.rel_original_ids = (
          graph_data_loader.backend.mapper.get_indexes(
              np.arange(rel_count_in_partition),
              type_of="r",
              order="ind2raw",
          )
      )
      """
          with shelve.open(graph_data_loader.backend.mapper.relations_dict) as partition:
              partition_keys = sorted([int(key) for key in partition.keys()])
              self.rel_original_ids = [partition[str(key)] for key in partition_keys]
          """
  
      with shelve.open(self.rel_map_fname) as partition:
          self.all_rel_embs = []
          self.all_rel_opt_params = []
          for key in self.rel_original_ids:
              self.all_rel_opt_params.append(partition[key][0])
              self.all_rel_embs.append(partition[key][1])
          self.all_rel_embs = np.concatenate(self.all_rel_embs, 0)
          self.all_rel_opt_params = np.concatenate(
              self.all_rel_opt_params, 0
          )
  
      # notify the model about the partition change
      self._model.partition_change_updates(
          len(self.ent_original_ids),
          self.all_ent_embs,
          self.all_rel_embs,
      )
  
      # Optimizer params will exist only after it has been persisted once
      if self._model.current_epoch > 1:
          # TODO: needs to be better handled
          # get the optimizer params of the embs that will be trained
          rel_optim_hyperparams = []
          ent_optim_hyperparams = []
  
          num_opt_hyperparams = (
              self._model.optimizer.get_hyperparam_count()
          )
          for i in range(num_opt_hyperparams):
              rel_hyperparam_i = self.all_rel_opt_params[:, i, :]
              rel_hyperparam_i = np.pad(
                  rel_hyperparam_i,
                  (
                      (0, self.num_rels - rel_hyperparam_i.shape[0]),
                      (0, 0),
                  ),
                  "constant",
                  constant_values=(0),
              )
              rel_optim_hyperparams.append(rel_hyperparam_i)
  
              ent_hyperparam_i = self.all_ent_opt_params[:, i, :]
              ent_hyperparam_i = np.pad(
                  ent_hyperparam_i,
                  (
                      (
                          0,
                          self.max_ent_size - ent_hyperparam_i.shape[0],
                      ),
                      (0, 0),
                  ),
                  "constant",
                  constant_values=(0),
              )
              ent_optim_hyperparams.append(ent_hyperparam_i)
  
          # notify the optimizer and update the optimizer hyperparams
          self._model.optimizer.set_entity_relation_hyperparams(
              ent_optim_hyperparams, rel_optim_hyperparams
          )
  
imports: import abc
  import glob
  import logging
  import os
  import shelve
  import shutil
  import tempfile
  from datetime import datetime
  import numpy
  import tensorflow
  from .graph_partitioner import PARTITION_ALGO_REGISTRY, AbstractGraphPartitioner
label_desc: Use image node_id 4 for calling the GeneralPartitionDataManager obj's underlying member method code with example usage: obj._change_partition(graph_data_loader, partition_number) without return types