code: def test_cross_entropy_in_out(
      batch_size: int,
      label_smoothing: float,
      ignore_index: int,
      class_weights: bool,
      num_classes: int,
  ) -> None:
      # These tests check the input and output formats are correct or not.
  
      # build configuration
      parser = argparse.ArgumentParser()
      parser = CrossEntropy.add_arguments(parser)
  
      opts = parser.parse_args([])
  
      setattr(
          opts,
          "loss.classification.cross_entropy.label_smoothing",
          label_smoothing,
      )
      setattr(
          opts,
          "loss.classification.cross_entropy.ignore_index",
          ignore_index,
      )
      setattr(
          opts,
          "loss.classification.cross_entropy.class_weights",
          class_weights,
      )
  
      criteria = CrossEntropy(opts)
  
      # Two prediction cases:
      # Case 1: Prediction is a tensor
      # Case 2: Prediction is a dictionary, with logits as a mandatory key
      pred_case_1 = torch.randn(size=(batch_size, num_classes))
      pred_case_2 = {
          "logits": torch.randn(size=(batch_size, num_classes))
      }
  
      target = torch.randint(
          low=0, high=num_classes, size=(batch_size,)
      )
      # this loss function does not care about it, so we can have any input
      input_sample = torch.randint(low=0, high=1, size=(1,))
      for pred in [pred_case_1, pred_case_2]:
          loss = criteria(input_sample, pred, target)
          assert isinstance(
              loss, torch.Tensor
          ), "Loss should be an instance of torch.Tensor"
          assert loss.dim() == 0, "Loss value should be a scalar"
  
imports: import argparse
  from typing import Mapping
  import pytest
  import torch
  from loss_fn.classification.binary_cross_entropy import BinaryCrossEntropy
  from loss_fn.classification.cross_entropy import CrossEntropy
label_desc: Use image node_id 1 for calling a global function with example usage: test_cross_entropy_in_out(batch_size, label_smoothing, ignore_index, class_weights, num_classes) without return types