code: def test_categorical_accuracy():
      from lasagne.objectives import categorical_accuracy
  
      p = theano.tensor.matrix("p")
      t = theano.tensor.ivector("t")
      c = categorical_accuracy(p, t)
      # numeric version
      floatX = theano.config.floatX
      predictions = np.random.rand(100, 5).astype(floatX)
      cls_predictions = np.argmax(predictions, axis=1)
      targets = np.random.random_integers(0, 4, (100,)).astype("int8")
      accuracy = cls_predictions == targets
      # compare
      assert np.allclose(accuracy, c.eval({p: predictions, t: targets}))
      one_hot = np.zeros((100, 5)).astype("int8")
      one_hot[np.arange(100), targets] = 1
      t = theano.tensor.imatrix("t")
      c = categorical_accuracy(p, t)
      assert np.allclose(accuracy, c.eval({p: predictions, t: one_hot}))
  
imports: import numpy
  import theano
  import pytest
label_desc: Use image node_id 19 for calling a global function with example usage: test_categorical_accuracy() without return types