code: def test_image_get_returns_valid_image_test(
      setup_image, image_format, width, height, scale
  ):
      # TODO: better understand why this intermittently fails. See #649
      data = setup_image
      num_attempts = 2
      for i in range(num_attempts):
          if i > 0:
              warnings.warn(
                  "image test intermittently failed, retrying..."
              )
          try:
              image = py.image.get(
                  data, image_format, width, height, scale
              )
              if image_format in ["png", "jpeg"]:
                  assert imghdr.what("", image) == image_format
              return
          except (KeyError, _plotly_utils.exceptions.PlotlyError):
              if i == num_attempts - 1:
                  raise
  
file_path: plotly.py/packages/python/chart-studio/chart_studio/tests/test_plot_ly/test_image/test_image.py
imports: from __future__ import absolute_import
  import imghdr
  import tempfile
  import os
  import itertools
  import warnings
  import pytest
  import _plotly_utils.exceptions
  from chart_studio.plotly import plotly
  from chart_studio.tests.utils import PlotlyTestCase
label_desc: Use image node_id 2 for calling a global function with example usage: test_image_get_returns_valid_image_test(setup_image, image_format, width, height, scale) without return types