code: def _find_candidate_parameters(
      hist: histograms.DatasetHistograms,
      parameters_to_tune: ParametersToTune,
      metric: Optional[pipeline_dp.Metric],
      max_candidates: int,
  ) -> analysis.MultiParameterConfiguration:
      """Finds candidates for l0, l_inf and max_sum_per_partition_bounds parameters.
  
      Args:
          hist: dataset contribution histogram.
          parameters_to_tune: which parameters to tune.
          metric: dp aggregation for which candidates are computed. If metric is
            None, it means no metrics to compute, i.e. only select partitions.
          max_candidates: how many candidates ((l0, linf) pairs) can be in the
            output. Note that output can contain fewer candidates. 100 is default
            heuristically chosen value, better to adjust it for your use-case.
      """
      calculate_l0_param = parameters_to_tune.max_partitions_contributed
      generate_linf_count = metric == pipeline_dp.Metrics.COUNT
      generate_max_sum_per_partition = metric == pipeline_dp.Metrics.SUM
      calculate_linf_count = (
          parameters_to_tune.max_contributions_per_partition
          and generate_linf_count
      )
      calculate_sum_per_partition_param = (
          parameters_to_tune.max_sum_per_partition
          and generate_max_sum_per_partition
      )
      l0_bounds = linf_bounds = None
      max_sum_per_partition_bounds = min_sum_per_partition_bounds = None
  
      if calculate_sum_per_partition_param:
          if hist.linf_sum_contributions_histogram.bins[0].lower < 0:
              logging.warning(
                  "max_sum_per_partition should not contain negative sums because"
                  " min_sum_per_partition tuning is not supported yet and "
                  "therefore tuning for max_sum_per_partition works only when "
                  "linf_sum_contributions_histogram does not negative sums"
              )
  
      if calculate_l0_param and calculate_linf_count:
          (
              l0_bounds,
              linf_bounds,
          ) = _find_candidates_parameters_in_2d_grid(
              hist.l0_contributions_histogram,
              hist.linf_contributions_histogram,
              _find_candidates_constant_relative_step,
              _find_candidates_constant_relative_step,
              max_candidates,
          )
      elif calculate_l0_param and calculate_sum_per_partition_param:
          (
              l0_bounds,
              max_sum_per_partition_bounds,
          ) = _find_candidates_parameters_in_2d_grid(
              hist.l0_contributions_histogram,
              hist.linf_sum_contributions_histogram,
              _find_candidates_constant_relative_step,
              _find_candidates_bins_max_values_subsample,
              max_candidates,
          )
          min_sum_per_partition_bounds = [0] * len(
              max_sum_per_partition_bounds
          )
      elif calculate_l0_param:
          l0_bounds = _find_candidates_constant_relative_step(
              hist.l0_contributions_histogram, max_candidates
          )
      elif calculate_linf_count:
          linf_bounds = _find_candidates_constant_relative_step(
              hist.linf_contributions_histogram, max_candidates
          )
      elif calculate_sum_per_partition_param:
          max_sum_per_partition_bounds = (
              _find_candidates_bins_max_values_subsample(
                  hist.linf_sum_contributions_histogram, max_candidates
              )
          )
          min_sum_per_partition_bounds = [0] * len(
              max_sum_per_partition_bounds
          )
      else:
          assert False, "Nothing to tune."
  
      return analysis.MultiParameterConfiguration(
          max_partitions_contributed=l0_bounds,
          max_contributions_per_partition=linf_bounds,
          min_sum_per_partition=min_sum_per_partition_bounds,
          max_sum_per_partition=max_sum_per_partition_bounds,
      )
  
imports: import logging
  import math
  from numbers import Number
  import pipeline_dp
  from pipeline_dp import dp_computations
  from pipeline_dp import pipeline_backend
  from pipeline_dp import input_validators
  from pipeline_dp.dataset_histograms import histograms
  import analysis
  from analysis import metrics
  from analysis import utility_analysis
  from analysis import dp_strategy_selector
  import dataclasses
  from dataclasses import dataclass
  from typing import Callable, List, Optional, Tuple, Union, Sequence
  from enum import Enum
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _find_candidate_parameters(hist, parameters_to_tune, metric, max_candidates) and returns: analysis