docstr: Test for updating prior Dirichlet parameters over sensory likelihood (pA)
  in the case that all observation modalities are updated and the generative model 
  has multiple hidden state factors
docstr_tok: ["Test","for","updating","prior","Dirichlet","parameters","over","sensory","likelihood","(","pA",")","in","the","case","that","all","observation","modalities","are","updated","and","the","generative","model","has","multiple","hidden","state","factors"]
code: def test_update_pA_multi_factor_all(self):
      """
      Test for updating prior Dirichlet parameters over sensory likelihood (pA)
      in the case that all observation modalities are updated and the generative model
      has multiple hidden state factors
      """
      num_states = [2, 6]
      qs = utils.random_single_categorical(num_states)
      l_rate = 1.0
  
      # single observation modality
      num_obs = [4]
      A = utils.random_A_matrix(num_obs, num_states)
      pA = utils.obj_array_ones([A_m.shape for A_m in A])
      observation = [utils.sample(maths.spm_dot(A_m, qs)) for A_m in A]
      pA_updated = learning.update_obs_likelihood_dirichlet(
          pA, A, observation, qs, lr=l_rate, modalities="all"
      )
      update = maths.spm_cross(
          utils.onehot(observation[0], num_obs[0]), qs
      )
      validation_pA = pA[0] + l_rate * update
      self.assertTrue(np.all(pA_updated[0] == validation_pA))
  
      # multiple observation modalities
      num_obs = [3, 4]
      A = utils.random_A_matrix(num_obs, num_states)
      pA = utils.obj_array_ones([A_m.shape for A_m in A])
      observation = [utils.sample(maths.spm_dot(A_m, qs)) for A_m in A]
      pA_updated = learning.update_obs_likelihood_dirichlet(
          pA, A, observation, qs, lr=l_rate, modalities="all"
      )
      for modality, obs_dim in enumerate(num_obs):
          update = maths.spm_cross(
              utils.onehot(observation[modality], obs_dim), qs
          )
          validation_pA = pA[modality] + l_rate * update
          self.assertTrue(np.all(pA_updated[modality] == validation_pA))
  
imports: import unittest
  import numpy
  from pymdp import utils, maths, learning
  from copy import deepcopy
label_desc: Use image node_id 4 for calling the TestLearning obj's underlying member method code with example usage: obj.test_update_pA_multi_factor_all() without return types