code: def test_apng_save_duration_loop(tmp_path):
      test_file = str(tmp_path / "temp.png")
      with Image.open("Tests/images/apng/delay.png") as im:
          frames = []
          durations = []
          loop = im.info.get("loop")
          default_image = im.info.get("default_image")
          for i, frame_im in enumerate(ImageSequence.Iterator(im)):
              frames.append(frame_im.copy())
              if i != 0 or not default_image:
                  durations.append(frame_im.info.get("duration", 0))
          frames[0].save(
              test_file,
              save_all=True,
              default_image=default_image,
              append_images=frames[1:],
              duration=durations,
              loop=loop,
          )
  
      with Image.open(test_file) as im:
          im.load()
          assert im.info.get("loop") == loop
          im.seek(1)
          assert im.info.get("duration") == 500.0
          im.seek(2)
          assert im.info.get("duration") == 1000.0
          im.seek(3)
          assert im.info.get("duration") == 500.0
          im.seek(4)
          assert im.info.get("duration") == 1000.0
  
      # test removal of duplicated frames
      frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255))
      frame.save(
          test_file,
          save_all=True,
          append_images=[frame, frame],
          duration=[500, 100, 150],
      )
      with Image.open(test_file) as im:
          im.load()
          assert im.n_frames == 1
          assert im.info.get("duration") == 750
  
      # test info duration
      frame.info["duration"] = 750
      frame.save(test_file, save_all=True)
      with Image.open(test_file) as im:
          assert im.info.get("duration") == 750
  
imports: import pytest
  from PIL import Image, ImageSequence, PngImagePlugin
label_desc: Use image node_id 17 for calling a global function with example usage: test_apng_save_duration_loop(tmp_path) without return types