class_docstr: Performs DP aggregations.
class_docstr_tok: ["Performs","DP","aggregations","."]
docstr: Implementation of select_partitions computational graph.
docstr_tok: ["Implementation","of","select_partitions","computational","graph","."]
code: def _select_partitions(
      self,
      col,
      params: pipeline_dp.SelectPartitionsParams,
      data_extractors: pipeline_dp.DataExtractors,
  ):
      """Implementation of select_partitions computational graph."""
      max_partitions_contributed = params.max_partitions_contributed
  
      # Extract the columns.
      col = self._backend.map(
          col,
          lambda row: (
              data_extractors.privacy_id_extractor(row),
              data_extractors.partition_extractor(row),
          ),
          "Extract (privacy_id, partition_key))",
      )
      # col : (privacy_id, partition_key)
  
      # Apply cross-partition contribution bounding
      col = self._backend.group_by_key(col, "Group by privacy_id")
  
      # col : (privacy_id, [partition_key])
  
      # Note: This may not be scalable if a single privacy ID contributes
      # to _way_ too many partitions.
      def sample_unique_elements_fn(pid_and_pks):
          pid, pks = pid_and_pks
          unique_pks = list(set(pks))
          sampled_elements = (
              sampling_utils.choose_from_list_without_replacement(
                  unique_pks, max_partitions_contributed
              )
          )
          return ((pid, pk) for pk in sampled_elements)
  
      col = self._backend.flat_map(
          col,
          sample_unique_elements_fn,
          "Sample cross-partition contributions",
      )
      # col : (privacy_id, partition_key)
  
      # A compound accumulator without any child accumulators is used to
      # calculate the raw privacy ID count.
      compound_combiner = combiners.CompoundCombiner(
          [], return_named_tuple=False
      )
      col = self._backend.map_tuple(
          col,
          lambda pid, pk: (
              pk,
              compound_combiner.create_accumulator([]),
          ),
          "Drop privacy id and add accumulator",
      )
      # col : (partition_key, accumulator)
  
      col = self._backend.combine_accumulators_per_key(
          col,
          compound_combiner,
          "Combine accumulators per partition key",
      )
      # col : (partition_key, accumulator)
  
      col = self._select_private_partitions_internal(
          col,
          max_partitions_contributed,
          max_rows_per_privacy_id=1,
          strategy=params.partition_selection_strategy,
          pre_threshold=params.pre_threshold,
      )
      col = self._backend.keys(
          col, "Drop accumulators, keep only partition keys"
      )
  
      return col
  
imports: import functools
  from typing import Any, Callable, Optional, Sequence, Tuple, Union
  import pipeline_dp
  from pipeline_dp import budget_accounting
  from pipeline_dp import combiners
  from pipeline_dp import contribution_bounders
  from pipeline_dp import dp_computations
  from pipeline_dp import partition_selection
  from pipeline_dp import pipeline_functions
  from pipeline_dp import report_generator
  from pipeline_dp import sampling_utils
  from pipeline_dp.dataset_histograms import computing_histograms
  from pipeline_dp.private_contribution_bounds import PrivateL0Calculator
label_desc: Use image node_id 11 for calling the DPEngine obj's underlying member method code with example usage: obj._select_partitions(col, params, data_extractors) and returns: col, unknown