code: def test_get_candidate_metadata_from_all_generator_runs(self) -> None:
      gr_1 = get_generator_run()
      gr_2 = get_generator_run2()
      self.batch.add_generator_run(gr_1)
      # Arms are named when adding GR to trial, so reassign to have a GR that has
      # names arms.
      gr_1 = self.batch._generator_run_structs[-1].generator_run
      self.batch.add_generator_run(gr_2)
      gr_2 = self.batch._generator_run_structs[-1].generator_run
      # gr_2 has no candidate metadata; all candidate metadata should come from gr_1
      cand_metadata_expected = {
          a.name: gr_1.candidate_metadata_by_arm_signature[a.signature]
          for a in gr_1.arms
      }
      self.assertEqual(
          self.batch._get_candidate_metadata_from_all_generator_runs(),
          cand_metadata_expected,
      )
      for arm in self.batch.arms:
          self.assertEqual(
              cand_metadata_expected[arm.name],
              self.batch._get_candidate_metadata(arm.name),
          )
      self.assertRaises(
          ValueError,
          self.batch._get_candidate_metadata,
          "this_is_not_an_arm",
      )
  
      # Check that if we add cand. metadata to gr_2, it will appear in cand.
      # metadata for the batch.
      gr_3 = get_generator_run2()
      new_cand_metadata = {
          a.signature: {"md_key": f"md_val_{a.signature}"}
          for a in gr_3.arms
      }
      # pyre-fixme[8]: Attribute has type `Optional[Dict[str, Optional[Dict[str,
      #  typing.Any]]]]`; used as `Dict[str, Dict[str, str]]`.
      gr_3._candidate_metadata_by_arm_signature = new_cand_metadata
      self.batch.add_generator_run(gr_3)
      gr_3 = self.batch._generator_run_structs[-1].generator_run
      cand_metadata_expected.update(
          {
              a.name: gr_1.candidate_metadata_by_arm_signature[
                  a.signature
              ]
              for a in gr_1.arms
          }
      )
      self.assertEqual(
          self.batch._get_candidate_metadata_from_all_generator_runs(),
          cand_metadata_expected,
      )
      for arm in self.batch.arms:
          self.assertEqual(
              cand_metadata_expected[arm.name],
              self.batch._get_candidate_metadata(arm.name),
          )
  
imports: import math
  from time import sleep
  from unittest import mock
  from unittest.mock import patch, PropertyMock
  import numpy
  from ax.core.arm import Arm
  from ax.core.base_trial import TrialStatus
  from ax.core.batch_trial import BatchTrial, GeneratorRunStruct
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun, GeneratorRunType
  from ax.core.parameter import FixedParameter, ParameterType
  from ax.core.search_space import SearchSpace
  from ax.runners.synthetic import SyntheticRunner
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import checked_cast
  from ax.utils.testing.core_stubs import get_abandoned_arm, get_arm, get_arm_weights1, get_arms, get_experiment, get_generator_run, get_generator_run2, get_weights
label_desc: Use image node_id 26 for calling the BatchTrialTest obj's underlying member method code with example usage: obj.test_get_candidate_metadata_from_all_generator_runs() without return types