class_docstr: Fetches AppMetric (the observation returned by the trial job/app) via the
  ``torchx.tracking`` module. Assumes that the app used the tracker in the
  following manner:
  
  .. code-block:: python
  
  tracker = torchx.runtime.tracking.FsspecResultTracker(tracker_base)
  tracker[str(trial_index)] = {metric_name: value}
  
  # -- or --
  tracker[str(trial_index)] = {"metric_name/mean": mean_value,
                              "metric_name/sem": sem_value}
class_docstr_tok: ["Fetches","AppMetric","(","the","observation","returned","by","the","trial","job\/app",")","via","the","``","torchx.tracking","``","module",".","Assumes","that","the","app","used","the","tracker","in","the","following","manner",":","..","code-block",":",":","python","tracker","=","torchx.runtime.tracking.FsspecResultTracker","(","tracker_base",")","tracker","[","str","(","trial_index",")","]","=","{","metric_name",":","value","}","#","--","or","--","tracker","[","str","(","trial_index",")","]","=","{","``","metric_name\/mean","''",":","mean_value",",","``","metric_name\/sem","''",":","sem_value","}"]
code: def fetch_trial_data(
      self, trial: BaseTrial, **kwargs: Any
  ) -> MetricFetchResult:
      try:
          tracker_base = trial.run_metadata[TORCHX_TRACKER_BASE]
          tracker = FsspecResultTracker(tracker_base)
          res = tracker[trial.index]
  
          if self.name in res:
              mean = res[self.name]
              sem = None
          else:
              mean = res.get(f"{self.name}/mean")
              sem = res.get(f"{self.name}/sem")
  
          if mean is None and sem is None:
              raise KeyError(
                  f"Observation for `{self.name}` not found in tracker at base "
                  f"`{tracker_base}`. Ensure that the trial job is writing the "
                  "results at the same tracker base."
              )
  
          df_dict = {
              "arm_name": not_none(cast(Trial, trial).arm).name,
              "trial_index": trial.index,
              "metric_name": self.name,
              "mean": mean,
              "sem": sem,
          }
          return Ok(value=Data(df=pd.DataFrame.from_records([df_dict])))
  
      except Exception as e:
          return Err(
              MetricFetchE(
                  message=f"Failed to fetch {self.name}", exception=e
              )
          )
  
file_path: Ax/ax/metrics/torchx.py
imports: from logging import Logger
  from typing import Any, cast
  import pandas
  from ax.core import Trial
  from ax.core.base_trial import BaseTrial
  from ax.core.data import Data
  from ax.core.metric import Metric, MetricFetchE, MetricFetchResult
  from ax.utils.common.logger import get_logger
  from ax.utils.common.result import Err, Ok
  from ax.utils.common.typeutils import not_none
label_desc: Use image node_id 1 for calling the TorchXMetric obj's underlying member method code with example usage: obj.fetch_trial_data(trial) and returns: Ok, Err