class_docstr: A Spark RDD counterpart.
  
  PrivateRDD guarantees that only data that has been aggregated 
  in a DP manner, using no more than the specified privacy 
  budget, can be extracted from it through its API.
  
  PrivateRDD keeps a `privacy_id` for each element
  in order to guarantee correct DP computations.
docstr: Computes a DP variance.
  
  Args:
      variance_params: parameters for calculation
      public_partitions: A collection of partition keys that will be
        present in the result. Optional. If not provided, partitions will be selected in a DP
        manner.
      out_explain_computaton_report: an output argument, if specified,
        it will contain the Explain Computation report for this
        aggregation. For more details see the docstring to
        report_generator.py.
docstr_tok: ["Computes","a","DP","variance",".","Args",":","variance_params",":","parameters","for","calculation","public_partitions",":","A","collection","of","partition","keys","that","will","be","present","in","the","result",".","Optional",".","If","not","provided",",","partitions","will","be","selected","in","a","DP","manner",".","out_explain_computaton_report",":","an","output","argument",",","if","specified",",","it","will","contain","the","Explain","Computation","report","for","this","aggregation",".","For","more","details","see","the","docstring","to","report_generator.py","."]
code: def variance(
      self,
      variance_params: aggregate_params.VarianceParams,
      public_partitions=None,
      out_explain_computaton_report: Optional[
          pipeline_dp.ExplainComputationReport
      ] = None,
  ) -> RDD:
      """Computes a DP variance.
  
      Args:
          variance_params: parameters for calculation
          public_partitions: A collection of partition keys that will be
            present in the result. Optional. If not provided, partitions will be selected in a DP
            manner.
          out_explain_computaton_report: an output argument, if specified,
            it will contain the Explain Computation report for this
            aggregation. For more details see the docstring to
            report_generator.py.
      """
  
      backend = pipeline_dp.SparkRDDBackend(self._rdd.context)
      dp_engine = pipeline_dp.DPEngine(self._budget_accountant, backend)
  
      params = pipeline_dp.AggregateParams(
          noise_kind=variance_params.noise_kind,
          metrics=[pipeline_dp.Metrics.VARIANCE],
          max_partitions_contributed=variance_params.max_partitions_contributed,
          max_contributions_per_partition=variance_params.max_contributions_per_partition,
          min_value=variance_params.min_value,
          max_value=variance_params.max_value,
          budget_weight=variance_params.budget_weight,
          contribution_bounds_already_enforced=variance_params.contribution_bounds_already_enforced,
      )
  
      value_extractor_needed = (
          not variance_params.contribution_bounds_already_enforced
      )
      data_extractors = pipeline_dp.DataExtractors(
          partition_extractor=lambda x: variance_params.partition_extractor(
              x[1]
          ),
          privacy_id_extractor=self._get_privacy_id_extractor(
              params.contribution_bounds_already_enforced
          ),
          value_extractor=lambda x: variance_params.value_extractor(
              x[1]
          ),
      )
  
      dp_result = dp_engine.aggregate(
          self._rdd,
          params,
          data_extractors,
          public_partitions,
          out_explain_computation_report=out_explain_computaton_report,
      )
      # dp_result : (partition_key, (variance=dp_variance))
  
      # aggregate() returns a namedtuple of metrics for each partition key.
      # Here is only one metric - variance. Extract it from the list.
      dp_result = backend.map_values(
          dp_result, lambda v: v.variance, "Extract variance"
      )
      # dp_result : (partition_key, dp_variance)
  
      return dp_result
  
file_path: pipelinedp/pipeline_dp/private_spark.py
imports: from pyspark import RDD
  from typing import Callable, Optional
  import pipeline_dp
  from pipeline_dp import aggregate_params, budget_accounting
label_desc: Use image node_id 4 for calling the PrivateRDD obj's underlying member method code with example usage: obj.variance(variance_params, public_partitions, out_explain_computaton_report) and returns: dp_result