code: def test_nll_loss(executor_kind, dev, target):
      def _get_oshape(target_shape, reduction):
          if reduction == "none":
              return target_shape
          else:
              return []
  
      def _verify(
          prediction_shape,
          reduction="mean",
          ignore_index=-100,
          dtype="float32",
      ):
          C = prediction_shape[1]
          target_shape = prediction_shape[:1] + prediction_shape[2:]
  
          predictions = relay.var(
              "predictions", relay.TensorType(prediction_shape, dtype)
          )
          targets = relay.var(
              "targets", relay.TensorType(target_shape, "int32")
          )
          weights = relay.var("weights", relay.TensorType((C,), dtype))
          out = relay.nn.nll_loss(
              predictions, targets, weights, reduction, ignore_index
          )
          checked = run_infer_type(out)
          assert checked.checked_type == relay.ty.TensorType(
              _get_oshape(target_shape, reduction), dtype
          )
          func = relay.Function([predictions, targets, weights], out)
          predictions_np = np.random.uniform(
              size=prediction_shape
          ).astype(dtype)
          targets_np = np.random.randint(0, C, target_shape).astype(
              "int32"
          )
          weights_np = np.random.uniform(size=(C,)).astype(dtype)
          out_np = tvm.topi.testing.nll_loss(
              predictions_np,
              targets_np,
              weights_np,
              reduction,
              ignore_index,
          )
  
          out_relay = relay.create_executor(
              executor_kind, device=dev, target=target
          ).evaluate(func)(predictions_np, targets_np, weights_np)
          tvm.testing.assert_allclose(
              out_relay.numpy(), out_np, rtol=1e-6, atol=1e-6
          )
  
      _verify((10, 5))
      _verify((10, 5, 2, 2))
      _verify((10, 5), reduction="sum")
      _verify((10, 5), reduction="none")
      _verify((10, 5), ignore_index=3)
      _verify((10, 5), dtype="float64")
  
imports: import sys
  import pytest
  import numpy
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay, te, topi
  from tvm.relay import transform
  from tvm.relay.testing import run_infer_type
label_desc: Use image node_id 33 for calling a global function with example usage: test_nll_loss(executor_kind, dev, target) and returns: target_shape, list