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: Sample or select a discrete action from the posterior over control states.
  This function both sets or cachés the action as an internal variable with the agent and returns it.
  This function also updates time variable (and thus manages consequences of updating the moving reference frame of beliefs)
  using ``self.step_time()``.
  
  Returns
  ----------
  action: 1D ``numpy.ndarray``
      Vector containing the indices of the actions for each control factor
docstr_tok: ["Sample","or","select","a","discrete","action","from","the","posterior","over","control","states",".","This","function","both","sets","or","cach\u00e9s","the","action","as","an","internal","variable","with","the","agent","and","returns","it",".","This","function","also","updates","time","variable","(","and","thus","manages","consequences","of","updating","the","moving","reference","frame","of","beliefs",")","using","``","self.step_time","(",")","``",".","Returns","--","--","--","--","--","action",":","1D","``","numpy.ndarray","``","Vector","containing","the","indices","of","the","actions","for","each","control","factor"]
code: def _sample_action_test(self):
      """
      Sample or select a discrete action from the posterior over control states.
      This function both sets or cachés the action as an internal variable with the agent and returns it.
      This function also updates time variable (and thus manages consequences of updating the moving reference frame of beliefs)
      using ``self.step_time()``.
  
      Returns
      ----------
      action: 1D ``numpy.ndarray``
          Vector containing the indices of the actions for each control factor
      """
  
      if self.sampling_mode == "marginal":
          action, p_dist = control._sample_action_test(
              self.q_pi,
              self.policies,
              self.num_controls,
              action_selection=self.action_selection,
              alpha=self.alpha,
          )
      elif self.sampling_mode == "full":
          action, p_dist = control._sample_policy_test(
              self.q_pi,
              self.policies,
              self.num_controls,
              action_selection=self.action_selection,
              alpha=self.alpha,
          )
  
      self.action = action
  
      self.step_time()
  
      return action, p_dist
  
imports: import warnings
  import numpy
  from pymdp import inference, control, learning
  from pymdp import utils, maths
  import copy
label_desc: Use image node_id 15 for calling the Agent obj's underlying member method code with example usage: obj._sample_action_test() and returns: action,  p_dist