code: def test_sequence_loss_class(
      average_across_timesteps, average_across_batch
  ):
      (
          batch_size,
          sequence_length,
          _,
          logits,
          targets,
          weights,
          expected_loss,
      ) = get_test_data()
      seq_loss = loss.SequenceLoss(
          average_across_timesteps=average_across_timesteps,
          average_across_batch=average_across_batch,
          sum_over_timesteps=False,
          sum_over_batch=False,
      )
      average_loss_per_example = seq_loss(targets, logits, weights)
      res = average_loss_per_example.numpy()
      if average_across_timesteps and average_across_batch:
          expected = expected_loss
      elif not average_across_timesteps and average_across_batch:
          expected = np.full(sequence_length, expected_loss)
      elif average_across_timesteps and not average_across_batch:
          expected = np.full(batch_size, expected_loss)
      elif not average_across_timesteps and not average_across_batch:
          expected = np.full(
              (batch_size, sequence_length), expected_loss
          )
  
      np.testing.assert_allclose(res, expected, atol=1e-6, rtol=1e-6)
  
file_path: addons/tensorflow_addons/seq2seq/tests/loss_test.py
imports: import pytest
  import numpy
  import tensorflow
  from tensorflow_addons.seq2seq import loss
label_desc: Use image node_id 3 for calling a global function with example usage: test_sequence_loss_class(average_across_timesteps, average_across_batch) without return types