code: def update_obs_likelihood_dirichlet(
      pA, A, obs, qs, lr=1.0, modalities="all"
  ):
      """
      Update Dirichlet parameters of the observation likelihood distribution.
  
      Parameters
      -----------
      pA: ``numpy.ndarray`` of dtype object
          Prior Dirichlet parameters over observation model (same shape as ``A``)
      A: ``numpy.ndarray`` of dtype object
          Sensory likelihood mapping or 'observation model', mapping from hidden states to observations. Each element ``A[m]`` of
          stores an ``numpy.ndarray`` multidimensional array for observation modality ``m``, whose entries ``A[m][i, j, k, ...]`` store
          the probability of observation level ``i`` given hidden state levels ``j, k, ...``
      obs: 1D ``numpy.ndarray``, ``numpy.ndarray`` of dtype object, ``int`` or ``tuple``
          The observation (generated by the environment). If single modality, this can be a 1D ``numpy.ndarray``
          (one-hot vector representation) or an ``int`` (observation index)
          If multi-modality, this can be ``numpy.ndarray`` of dtype object whose entries are 1D one-hot vectors,
          or a ``tuple`` (of ``int``)
      qs: 1D ``numpy.ndarray`` or ``numpy.ndarray`` of dtype object, default None
          Marginal posterior beliefs over hidden states at current timepoint.
      lr: float, default 1.0
          Learning rate, scale of the Dirichlet pseudo-count update.
      modalities: ``list``, default "all"
          Indices (ranging from 0 to ``n_modalities - 1``) of the observation modalities to include
          in learning. Defaults to "all", meaning that modality-specific sub-arrays of ``pA``
          are all updated using the corresponding observations.
  
      Returns
      -----------
      qA: ``numpy.ndarray`` of dtype object
          Posterior Dirichlet parameters over observation model (same shape as ``A``), after having updated it with observations.
      """
  
      num_modalities = len(pA)
      num_observations = [
          pA[modality].shape[0] for modality in range(num_modalities)
      ]
  
      obs_processed = utils.process_observation(
          obs, num_modalities, num_observations
      )
      obs = utils.to_obj_array(obs_processed)
  
      if modalities == "all":
          modalities = list(range(num_modalities))
  
      qA = copy.deepcopy(pA)
  
      for modality in modalities:
          dfda = maths.spm_cross(obs[modality], qs)
          dfda = dfda * (A[modality] > 0).astype("float")
          qA[modality] = qA[modality] + (lr * dfda)
  
      return qA
  
file_path: pymdp/pymdp/learning.py
imports: import numpy
  from pymdp import utils, maths
  import copy
label_desc: Use image node_id 1 for calling a global function with example usage: update_obs_likelihood_dirichlet(pA, A, obs, qs, lr, modalities) and returns: qA