code: def test_categorical_crossentropy(guesses, labels):
      d_scores = CategoricalCrossentropy(normalize=True).get_grad(
          guesses, labels
      )
      assert d_scores.shape == guesses.shape
  
      # The normalization divides the difference (e.g. 0.4) by the number of vectors (4)
      assert d_scores[1][0] == pytest.approx(0.1, eps)
      assert d_scores[1][1] == pytest.approx(-0.1, eps)
  
      # The third vector predicted all labels, but only the first one was correct
      assert d_scores[2][0] == pytest.approx(0, eps)
      assert d_scores[2][1] == pytest.approx(0.25, eps)
      assert d_scores[2][2] == pytest.approx(0.25, eps)
  
      # The fourth vector predicted no labels but should have predicted the last one
      assert d_scores[3][0] == pytest.approx(0, eps)
      assert d_scores[3][1] == pytest.approx(0, eps)
      assert d_scores[3][2] == pytest.approx(-0.25, eps)
  
      loss = CategoricalCrossentropy(normalize=True).get_loss(
          guesses, labels
      )
      assert loss == pytest.approx(0.239375, eps)
  
file_path: thinc/thinc/tests/test_loss.py
imports: import numpy
  import pytest
  from thinc import registry
  from thinc.api import CategoricalCrossentropy, CosineDistance, L2Distance, SequenceCategoricalCrossentropy
label_desc: Use image node_id 3 for calling a global function with example usage: test_categorical_crossentropy(guesses, labels) without return types