code: def test_poisson_nllloss(hybridize):
      shape = (3, 4)
      not_axis0 = tuple(range(1, len(shape)))
      pred = mx.np.random.normal(size=shape)
      min_pred = mx.np.min(pred)
      # This is necessary to ensure only positive random values are generated for prediction,
      # to avoid ivalid log calculation
      pred[:] = pred + mx.np.abs(min_pred)
      target = mx.np.random.normal(size=shape)
      min_target = mx.np.min(target)
      # This is necessary to ensure only positive random values are generated for prediction,
      # to avoid ivalid log calculation
      target[:] += mx.np.abs(min_target)
  
      Loss = gluon.loss.PoissonNLLLoss(from_logits=True)
      if hybridize:
          Loss.hybridize()
      Loss_no_logits = gluon.loss.PoissonNLLLoss(from_logits=False)
      if hybridize:
          Loss_no_logits.hybridize()
      # Calculating by brute formula for default value of from_logits = True
  
      # 1) Testing for flag logits = True
      brute_loss = mx.np.mean(mx.np.exp(pred) - target * pred, axis=1)
      loss_withlogits = Loss(pred, target)
      assert_almost_equal(brute_loss, loss_withlogits)
  
      # 2) Testing for flag logits = False
      loss_no_logits = Loss_no_logits(pred, target)
      np_loss_no_logits = mx.np.mean(
          pred - target * mx.np.log(pred + 1e-08), axis=1
      )
      assert_almost_equal(np_loss_no_logits, loss_no_logits)
  
      # 3) Testing for Sterling approximation
      shape = (2, 3)
      np_pred = mx.np.random.uniform(1, 5, shape)
      np_target = mx.np.random.uniform(1, 5, shape)
      np_compute_full = mx.np.mean(
          (np_pred - np_target * mx.np.log(np_pred + 1e-08))
          + (
              (
                  np_target * onp.log(np_target)
                  - np_target
                  + 0.5 * onp.log(2 * np_target * onp.pi)
              )
              * (np_target > 1)
          ),
          axis=1,
      )
      Loss_compute_full = gluon.loss.PoissonNLLLoss(
          from_logits=False, compute_full=True
      )
      if hybridize:
          Loss_compute_full.hybridize()
      loss_compute_full = Loss_compute_full(np_pred, np_target)
      assert_almost_equal(np_compute_full, loss_compute_full)
  
file_path: mxnet/tests/python/unittest/test_numpy_loss.py
imports: import mxnet
  import numpy
  from mxnet import gluon, autograd
  from mxnet.test_utils import assert_almost_equal, default_device, use_np
  from common import xfail_when_nonstandard_decimal_separator
  import pytest
label_desc: Use image node_id 7 for calling a global function with example usage: test_poisson_nllloss(hybridize) without return types