code: def test_multiclass_hinge_loss():
      from lasagne.objectives import multiclass_hinge_loss
      from lasagne.nonlinearities import rectify
  
      p = theano.tensor.matrix("p")
      t = theano.tensor.ivector("t")
      c = multiclass_hinge_loss(p, t)
      # numeric version
      floatX = theano.config.floatX
      predictions = np.random.rand(10, 20).astype(floatX)
      targets = np.random.random_integers(0, 19, (10,)).astype("int8")
      one_hot = np.zeros((10, 20))
      one_hot[np.arange(10), targets] = 1
      correct = predictions[one_hot > 0]
      rest = predictions[one_hot < 1].reshape((10, 19))
      rest = np.max(rest, axis=1)
      hinge = rectify(1 + rest - correct)
      # compare
      assert np.allclose(hinge, c.eval({p: predictions, t: targets}))
  
imports: import numpy
  import theano
  import pytest
label_desc: Use image node_id 16 for calling a global function with example usage: test_multiclass_hinge_loss() without return types