code: def test_contribution_bounding_cross_partition_bounding_applied(self):
      input = [
          ("pid1", "pk1", 1),
          ("pid1", "pk1", 2),
          ("pid1", "pk2", 3),
          ("pid1", "pk2", 4),
          ("pid1", "pk2", 5),
          ("pid1", "pk3", 6),
          ("pid1", "pk4", 7),
          ("pid2", "pk4", 8),
      ]
      max_partitions_contributed = 3
      max_contributions_per_partition = 5
  
      bound_result = self._run_contribution_bounding(
          input,
          max_partitions_contributed,
          max_contributions_per_partition,
      )
  
      self.assertEqual(4, len(bound_result))
      # Check contributions per partitions are enforced.
      self.assertTrue(
          all(
              map(
                  lambda op_val: op_val[1][0]
                  <= max_contributions_per_partition,
                  bound_result,
              )
          )
      )
      # Check cross partition contributions are enforced.
      dict_of_pid_to_pk = collections.defaultdict(lambda: [])
      for key, _ in bound_result:
          dict_of_pid_to_pk[key[0]].append(key[1])
      self.assertEqual(2, len(dict_of_pid_to_pk))
      self.assertTrue(
          all(
              map(
                  lambda key: len(dict_of_pid_to_pk[key])
                  <= max_partitions_contributed,
                  dict_of_pid_to_pk,
              )
          )
      )
  
file_path: pipelinedp/tests/contribution_bounders_test.py
imports: import collections
  import numpy
  from absl.testing import parameterized
  import pipeline_dp
  import pipeline_dp.contribution_bounders
label_desc: Use image node_id 5 for calling the SamplingCrossAndPerPartitionContributionBounderTest obj's underlying member method code with example usage: obj.test_contribution_bounding_cross_partition_bounding_applied() without return types