code: def test_median_absolute_percentage_error_2():
      np.random.seed(1)
      size = 105
      np_y_pred = np.random.rand(size, 1)
      np_y = np.random.rand(size, 1)
      np.random.shuffle(np_y)
      np_median_absolute_percentage_error = 100.0 * np.median(
          np.abs(np_y - np_y_pred) / np.abs(np_y)
      )
  
      m = MedianAbsolutePercentageError()
      y_pred = torch.from_numpy(np_y_pred)
      y = torch.from_numpy(np_y)
  
      m.reset()
      batch_size = 16
      n_iters = size // batch_size + 1
      for i in range(n_iters):
          idx = i * batch_size
          m.update(
              (
                  y_pred[idx : idx + batch_size],
                  y[idx : idx + batch_size],
              )
          )
  
      assert np_median_absolute_percentage_error == pytest.approx(
          m.compute()
      )
  
imports: import os
  import numpy
  import pytest
  import torch
  import ignite.distributed
  from ignite.contrib.metrics.regression import MedianAbsolutePercentageError
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
label_desc: Use image node_id 4 for calling a global function with example usage: test_median_absolute_percentage_error_2() without return types