code: def test_update_trial_data(self) -> None:
      # Verify components before we attach trial data
      self.assertEqual(1, len(self.trial.arms))
      arm_name = self.trial.arm.name
  
      self.assertEqual(
          2,
          len(self.trial.experiment.metrics)
          - len(self.trial.experiment.tracking_metrics),
      )
      self.assertTrue("m1" in self.trial.experiment.metrics)
      self.assertTrue("m2" in self.trial.experiment.metrics)
  
      data = self.trial.lookup_data().df.to_dict(orient="index")
      self.assertTrue(len(data) == 0)
  
      # Attach data
      self.trial.update_trial_data(raw_data={"m1": 1.0, "m2": 2.0})
  
      # Confirm the expected state after attaching data
      data = (
          self.trial.lookup_data()
          .df.set_index(["arm_name", "metric_name"])
          .to_dict(orient="index")
      )
  
      self.assertEqual(1.0, data[(arm_name, "m1")]["mean"])
      self.assertEqual(2.0, data[(arm_name, "m2")]["mean"])
  
      # Try to attach MapData.
      with self.assertRaisesRegex(
          UserInputError,
          "The format of the `raw_data` is not compatible with `Data`. ",
      ):
          self.trial.update_trial_data(
              raw_data=[({"time": 0}, {"m1": 1.0})]
          )
  
      # Try to attach Data to a MapData experiment.
      map_experiment = get_test_map_data_experiment(
          num_trials=3, num_fetches=2, num_complete=1
      )
      map_trial = map_experiment.new_trial().add_arm(
          arm=get_branin_arms(n=1, seed=0)[0]
      )
      map_trial.update_trial_data(raw_data=[({"time": 0}, {"m1": 1.0})])
      with self.assertRaisesRegex(
          UserInputError,
          "The format of the `raw_data` is not compatible with `MapData`. ",
      ):
          map_trial.update_trial_data(raw_data={"m1": 1.0})
  
      # Error if the MapData inputs are not formatted correctly.
      with self.assertRaisesRegex(
          UserInputError,
          "Raw data does not conform to the expected structure.",
      ):
          map_trial.update_trial_data(raw_data=[["aa", {"m1": 1.0}]])
  
imports: import itertools
  from copy import deepcopy
  from unittest import mock
  from unittest.mock import Mock, patch
  import pandas
  from ax.core.base_trial import BaseTrial, TrialStatus
  from ax.core.data import Data
  from ax.core.generator_run import GeneratorRun, GeneratorRunType
  from ax.core.runner import Runner
  from ax.exceptions.core import UserInputError
  from ax.runners.synthetic import SyntheticRunner
  from ax.utils.common.result import Ok
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_arms, get_branin_arms, get_experiment, get_objective, get_test_map_data_experiment
label_desc: Use image node_id 17 for calling the TrialTest obj's underlying member method code with example usage: obj.test_update_trial_data() without return types