code: def test_ObservationsFromDataAbandoned(self) -> None:
      truth = {
          0.5: {
              "arm_name": "0_0",
              "parameters": {"x": 0, "y": "a", "z": 1},
              "mean": 2.0,
              "sem": 2.0,
              "trial_index": 0,
              "metric_name": "a",
              "updated_parameters": {"x": 0, "y": "a", "z": 0.5},
              "mean_t": np.array([2.0]),
              "covariance_t": np.array([[4.0]]),
              "z": 0.5,
              "timestamp": 50,
          },
          1: {
              "arm_name": "1_0",
              "parameters": {"x": 0, "y": "a", "z": 1},
              "mean": 4.0,
              "sem": 4.0,
              "trial_index": 1,
              "metric_name": "b",
              "updated_parameters": {"x": 0, "y": "a", "z": 1},
              "mean_t": np.array([4.0]),
              "covariance_t": np.array([[16.0]]),
              "z": 1,
              "timestamp": 100,
          },
          0.25: {
              "arm_name": "2_0",
              "parameters": {"x": 1, "y": "a", "z": 0.5},
              "mean": 3.0,
              "sem": 3.0,
              "trial_index": 2,
              "metric_name": "a",
              "updated_parameters": {"x": 1, "y": "b", "z": 0.25},
              "mean_t": np.array([3.0]),
              "covariance_t": np.array([[9.0]]),
              "z": 0.25,
              "timestamp": 25,
          },
          0.75: {
              "arm_name": "2_1",
              "parameters": {"x": 1, "y": "b", "z": 0.75},
              "mean": 3.0,
              "sem": 3.0,
              "trial_index": 2,
              "metric_name": "a",
              "updated_parameters": {"x": 1, "y": "b", "z": 0.75},
              "mean_t": np.array([3.0]),
              "covariance_t": np.array([[9.0]]),
              "z": 0.75,
              "timestamp": 25,
          },
      }
      arms = {
          # pyre-fixme[6]: For 1st param expected `Optional[str]` but got
          #  `Union[Dict[str, Union[float, str]], Dict[str, Union[int, str]], float,
          #  ndarray, str]`.
          # pyre-fixme[6]: For 2nd param expected `Dict[str, Union[None, bool,
          #  float, int, str]]` but got `Union[Dict[str, Union[float, str]],
          #  Dict[str, Union[int, str]], float, ndarray, str]`.
          obs["arm_name"]: Arm(
              name=obs["arm_name"], parameters=obs["parameters"]
          )
          for _, obs in truth.items()
      }
      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"]]])
              )
          )
          for _, obs in list(truth.items())[:-1]
          # pyre-fixme[16]: Item `Dict` of `Union[Dict[str, typing.Union[float,
          #  str]], Dict[str, typing.Union[int, str]], float, ndarray, str]` has no
          #  attribute `startswith`.
          if not obs["arm_name"].startswith("2")
      }
      batch = BatchTrial(
          experiment, GeneratorRun(arms=[arms["2_0"], arms["2_1"]])
      )
      # pyre-fixme[6]: For 1st param expected
      #  `SupportsKeysAndGetItem[Union[Dict[str, Union[float, str]], Dict[str,
      #  Union[int, str]], float, ndarray, str], Trial]` but got `Dict[int,
      #  BatchTrial]`.
      trials.update({2: batch})
      # pyre-fixme[16]: Optional type has no attribute `mark_abandoned`.
      trials.get(1).mark_abandoned()
      # pyre-fixme[16]: Optional type has no attribute `mark_arm_abandoned`.
      trials.get(2).mark_arm_abandoned(arm_name="2_1")
      type(experiment).arms_by_name = PropertyMock(return_value=arms)
      type(experiment).trials = PropertyMock(return_value=trials)
  
      df = pd.DataFrame(list(truth.values()))[
          ["arm_name", "trial_index", "mean", "sem", "metric_name"]
      ]
      data = Data(df=df)
  
      # 1 arm is abandoned and 1 trial is abandoned, so only 2 observations should be
      # included.
      obs_no_abandoned = observations_from_data(experiment, data)
      self.assertEqual(len(obs_no_abandoned), 2)
  
      # 1 arm is abandoned and 1 trial is abandoned, so only 2 observations should be
      # included.
      obs_with_abandoned = observations_from_data(
          experiment, data, include_abandoned=True
      )
      self.assertEqual(len(obs_with_abandoned), 4)
  
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 12 for calling the ObservationsTest obj's underlying member method code with example usage: obj.test_ObservationsFromDataAbandoned() without return types