code: def _checkRewardsListLike(reward, n_actions, n_states):
      
      try:
          lenR = len(reward)
          if lenR == n_actions:
              dim1, dim2, dim3 = _checkDimensionsListLike(reward)
          elif lenR == n_states:
              dim1 = n_actions
              dim2 = dim3 = lenR
          else:
              raise _error.InvalidError(_MDPERR["R_shape"])
      except AttributeError:
          raise _error.InvalidError(_MDPERR["R_shape"])
      return dim1, dim2, dim3
docs: Check that a list-like reward input is valid.