code: def extract_mean_or_value(cls, obs_or_pred, key=None):
          
  
          result = None
          if not isinstance(obs_or_pred, dict):
              result = obs_or_pred
          else:
              keys = ([key] if key is not None else []) + ['mean', 'value']
              for k in keys:
                  if k in obs_or_pred:
                      result = obs_or_pred[k]
                      break
              if result is None:
                  raise KeyError(("%s has neither a mean nor a single "
                                  "value" % obs_or_pred))
          return result
docs: Extracts the mean, value, or user-provided key from an observation
          or prediction dictionary.