class_docstr: The Agent class, the highest-level API that wraps together processes for action, perception, and learning under active inference.
  
  The basic usage is as follows:
  
  >>> my_agent = Agent(A = A, B = C, <more_params>)
  >>> observation = env.step(initial_action)
  >>> qs = my_agent.infer_states(observation)
  >>> q_pi, G = my_agent.infer_policies()
  >>> next_action = my_agent.sample_action()
  >>> next_observation = env.step(next_action)
  
  This represents one timestep of an active inference process. Wrapping this step in a loop with an ``Env()`` class that returns
  observations and takes actions as inputs, would entail a dynamic agent-environment interaction.
class_docstr_tok: ["The","Agent","class",",","the","highest-level","API","that","wraps","together","processes","for","action",",","perception",",","and","learning","under","active","inference",".","The","basic","usage","is","as","follows",":",">",">",">","my_agent","=","Agent","(","A","=","A",",","B","=","C",",","<","more_params",">",")",">",">",">","observation","=","env.step","(","initial_action",")",">",">",">","qs","=","my_agent.infer_states","(","observation",")",">",">",">","q_pi",",","G","=","my_agent.infer_policies","(",")",">",">",">","next_action","=","my_agent.sample_action","(",")",">",">",">","next_observation","=","env.step","(","next_action",")","This","represents","one","timestep","of","an","active","inference","process",".","Wrapping","this","step","in","a","loop","with","an","``","Env","(",")","``","class","that","returns","observations","and","takes","actions","as","inputs",",","would","entail","a","dynamic","agent-environment","interaction","."]
docstr: Test version of ``infer_states()`` that additionally returns intermediate variables of MMP, such as
  the prediction errors and intermediate beliefs from the optimization. Used for benchmarking against SPM outputs.
docstr_tok: ["Test","version","of","``","infer_states","(",")","``","that","additionally","returns","intermediate","variables","of","MMP",",","such","as","the","prediction","errors","and","intermediate","beliefs","from","the","optimization",".","Used","for","benchmarking","against","SPM","outputs","."]
code: def _infer_states_test(self, observation):
      """
      Test version of ``infer_states()`` that additionally returns intermediate variables of MMP, such as
      the prediction errors and intermediate beliefs from the optimization. Used for benchmarking against SPM outputs.
      """
      observation = tuple(observation)
  
      if not hasattr(self, "qs"):
          self.reset()
  
      if self.inference_algo == "VANILLA":
          if self.action is not None:
              empirical_prior = control.get_expected_states(
                  self.qs, self.B, self.action.reshape(1, -1)  # type: ignore
              )
          else:
              empirical_prior = self.D
          qs = inference.update_posterior_states(
              self.A,
              observation,
              empirical_prior,
              **self.inference_params,
          )
      elif self.inference_algo == "MMP":
          self.prev_obs.append(observation)
          if len(self.prev_obs) > self.inference_horizon:
              latest_obs = self.prev_obs[-self.inference_horizon :]
              latest_actions = self.prev_actions[
                  -(self.inference_horizon - 1) :
              ]
          else:
              latest_obs = self.prev_obs
              latest_actions = self.prev_actions
  
          qs, F, xn, vn = inference._update_posterior_states_full_test(
              self.A,
              self.B,
              latest_obs,
              self.policies,
              latest_actions,
              prior=self.latest_belief,
              policy_sep_prior=self.edge_handling_params[
                  "policy_sep_prior"
              ],
              **self.inference_params,
          )
  
          self.F = F  # variational free energy of each policy
  
      if hasattr(self, "qs_hist"):
          self.qs_hist.append(qs)
  
      self.qs = qs
  
      return qs, xn, vn
  
imports: import warnings
  import numpy
  from pymdp import inference, control, learning
  from pymdp import utils, maths
  import copy
label_desc: Use image node_id 12 for calling the Agent obj's underlying member method code with example usage: obj._infer_states_test(observation) and returns: qs,  xn,  vn