code: def test_write_image(monkeypatch, single_with_trials, out_type):
      """Test all types for images use write_image"""
  
      def mock_write_image(*args, **kwargs):
          mock_write_image.called = True
          return ""
  
      mock_write_image.called = False
  
      monkeypatch.setattr(
          "plotly.graph_objs._figure.Figure.write_image",
          mock_write_image,
      )
  
      returncode = orion.core.cli.main(
          [
              "plot",
              "regret",
              "--name",
              "test_single_exp",
              "--type",
              out_type,
          ]
      )
      assert returncode == 0
  
      assert mock_write_image.called
  
imports: import random
  import pytest
  import orion.core.cli
  import orion.plotting.backend_plotly
  from orion.core.cli.plot import IMAGE_TYPES, VALID_TYPES
  from orion.plotting.base import SINGLE_EXPERIMENT_PLOTS
  from orion.storage.base import setup_storage
  from orion.testing import AssertNewFile
label_desc: Use image node_id 16 for calling a global function with example usage: test_write_image(monkeypatch, single_with_trials, out_type) and returns: str