old_contents: import matplotlib.pyplot as plt
  
  
  def imshow(*args, **kwargs):
      kwargs.setdefault('interpolation', 'nearest')
      kwargs.setdefault('cmap', 'gray')
      plt.imshow(*args, **kwargs)
  
  imread = plt.imread
  show = plt.show
  
  
  def _app_show():
      show()
  
new_contents: import matplotlib.pyplot as plt
  
  
  def imshow(*args, **kwargs):
      if plt.gca().has_data():
          plt.figure()
      kwargs.setdefault('interpolation', 'nearest')
      kwargs.setdefault('cmap', 'gray')
      plt.imshow(*args, **kwargs)
  
  imread = plt.imread
  show = plt.show
  
  
  def _app_show():
      show()
  
subject: Create a new figure for imshow if there is already data