code: def test_ObservationsWithCandidateMetadata(self) -> None:
      SOME_METADATA_KEY = "metadatum"
      truth = [
          {
              "arm_name": "0_0",
              "parameters": {"x": 0, "y": "a"},
              "mean": 2.0,
              "sem": 2.0,
              "trial_index": 0,
              "metric_name": "a",
          },
          {
              "arm_name": "1_0",
              "parameters": {"x": 1, "y": "b"},
              "mean": 3.0,
              "sem": 3.0,
              "trial_index": 1,
              "metric_name": "a",
          },
      ]
      arms = {
          # pyre-fixme[6]: For 1st param expected `Optional[str]` but got
          #  `Union[Dict[str, Union[int, str]], float, str]`.
          # pyre-fixme[6]: For 2nd param expected `Dict[str, Union[None, bool,
          #  float, int, str]]` but got `Union[Dict[str, Union[int, str]], float,
          #  str]`.
          obs["arm_name"]: Arm(
              name=obs["arm_name"], parameters=obs["parameters"]
          )
          for obs in truth
      }
      experiment = Mock()
      experiment._trial_indices_by_status = {
          status: set() for status in TrialStatus
      }
      trials = {
          obs["trial_index"]: Trial(
              experiment,
              GeneratorRun(
                  arms=[arms[obs["arm_name"]]],
                  candidate_metadata_by_arm_signature={
                      arms[obs["arm_name"]].signature: {
                          SOME_METADATA_KEY: f"value_{obs['trial_index']}"
                      }
                  },
              ),
          )
          for obs in truth
      }
      type(experiment).arms_by_name = PropertyMock(return_value=arms)
      type(experiment).trials = PropertyMock(return_value=trials)
  
      df = pd.DataFrame(truth)[
          ["arm_name", "trial_index", "mean", "sem", "metric_name"]
      ]
      data = Data(df=df)
      observations = observations_from_data(experiment, data)
      for observation in observations:
          self.assertEqual(
              # pyre-fixme[16]: Optional type has no attribute `get`.
              observation.features.metadata.get(SOME_METADATA_KEY),
              f"value_{observation.features.trial_index}",
          )
  
imports: import json
  from unittest.mock import Mock, PropertyMock
  import numpy
  import pandas
  from ax.core.arm import Arm
  from ax.core.base_trial import TrialStatus
  from ax.core.batch_trial import BatchTrial
  from ax.core.data import Data
  from ax.core.generator_run import GeneratorRun
  from ax.core.map_data import MapData, MapKeyInfo
  from ax.core.observation import Observation, ObservationData, ObservationFeatures, observations_from_data, observations_from_map_data, recombine_observations, separate_observations
  from ax.core.trial import Trial
  from ax.utils.common.testutils import TestCase
label_desc: Use image node_id 15 for calling the ObservationsTest obj's underlying member method code with example usage: obj.test_ObservationsWithCandidateMetadata() without return types