class_docstr: Image event adapter 
class_docstr_tok: ["Image","event","adapter"]
code: def __init__(
      self,
      metric,
      variant,
      image_data,
      local_image_path=None,
      iter=0,
      upload_uri=None,
      file_history_size=None,
      delete_after_upload=False,
      **kwargs,
  ):
      # param override_filename: override uploaded file name (notice extension will be added from local path
      # param override_filename_ext: override uploaded file extension
      if image_data is not None and (
          not hasattr(image_data, "shape")
          and not isinstance(image_data, (six.StringIO, six.BytesIO))
      ):
          raise ValueError("Image must have a shape attribute")
      self._image_data = image_data
      self._local_image_path = local_image_path
      self._url = None
      self._key = None
      self._count = None
      self._filename = None
      self.file_history_size = file_history_size or int(
          self._file_history_size
      )
      self._override_filename = kwargs.pop("override_filename", None)
      self._upload_uri = upload_uri
      self._delete_after_upload = delete_after_upload
      # get upload uri upfront, either predefined image format or local file extension
      # e.g.: image.png -> .png or image.raw.gz -> .raw.gz
      self._override_filename_ext = kwargs.pop(
          "override_filename_ext", None
      )
      self._upload_filename = None
  
      self._override_storage_key_prefix = kwargs.pop(
          "override_storage_key_prefix", None
      )
      self.retries = self._upload_retries
      super(UploadEvent, self).__init__(
          metric, variant, iter=iter, **kwargs
      )
  
imports: import abc
  import hashlib
  import time
  from functools import reduce
  from logging import getLevelName
  import attr
  import numpy
  import pathlib2
  import six
  from PIL import Image
  from six.moves.urllib.parse import urlparse, urlunparse
  from ...backend_api.services import events
  from ...config import deferred_config
  from ...debugging.log import LoggerRoot
  from ...storage.util import quote_url
  from ...utilities.attrs import attrs
  from ...utilities.process.mp import SingletonLock
label_desc: Use image node_id 2 to create a new UploadEvent object from inherited base classes: MetricsEventAdapter with example: obj = UploadEvent(metric, variant, image_data, local_image_path, iter, upload_uri, file_history_size, delete_after_upload)