class_docstr: Manages the partitioning related controls.
  
  Handles data generation and informs model about changes in partition.
class_docstr_tok: ["Manages","the","partitioning","related","controls",".","Handles","data","generation","and","informs","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.
      """
      try:
          # open the meta data related to the partition
          s = shelve.open(self.ent_meta_fname)
          # entities mapping ids
          self.ent_original_ids = s[str(partition_number)]
      finally:
          s.close()
  
      try:
          s = shelve.open(self.rel_meta_fname)
          # entities mapping ids
          self.rel_original_ids = s[str(partition_number)]
  
      finally:
          s.close()
  
      # Open the buckets related to the partition and concat
      splits = graph_data_loader.backend.mapper.metadata["name"].split(
          "-"
      )
      source_bucket = splits[0][-1]
      dest_bucket = splits[1]
  
      try:
          s = shelve.open(self.ent_map_fname)
          source_bucket_params = s[source_bucket]
          dest_source_bucket_params = s[dest_bucket]
          # full ent embs
          self.all_ent_embs = np.concatenate(
              [source_bucket_params[1], dest_source_bucket_params[1]]
          )
          self.split_emb_idx = source_bucket_params[1].shape[0]
  
          self.all_ent_opt_params = np.concatenate(
              [source_bucket_params[0], dest_source_bucket_params[0]]
          )
          self.split_opt_idx = source_bucket_params[0].shape[0]
  
          # now select only partition embeddings
          ent_embs = self.all_ent_embs[self.ent_original_ids]
          ent_opt_params = self.all_ent_opt_params[
              self.ent_original_ids
          ]
      finally:
          s.close()
  
      try:
          s = shelve.open(self.rel_map_fname)
          # full rel embs
          self.all_rel_embs = s["0"][1]
          self.all_rel_opt_params = s["0"][0]
          # now select only partition embeddings
          rel_embs = self.all_rel_embs[self.rel_original_ids]
          rel_opt_params = self.all_rel_opt_params[
              self.rel_original_ids
          ]
      finally:
          s.close()
  
      # notify the model about the partition change
      self._model.partition_change_updates(
          len(self.ent_original_ids), ent_embs, rel_embs
      )
  
      # Optimizer params will exist only after it has been persisted once
      if self._model.current_epoch > 1 or (
          self._model.current_epoch == 1
          and partition_number > self.partitioner_k
      ):
          # 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 = 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 = 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 BucketPartitionDataManager obj's underlying member method code with example usage: obj._change_partition(graph_data_loader, partition_number) without return types