class_docstr: Image event adapter 
class_docstr_tok: ["Image","event","adapter"]
code: def get_file_entry(self):
      self._generate_file_name()
  
      local_file = None
  
      # Notice that in case we are running with reporter in subprocess,
      # when we are here, the cls._metric_counters is actually empty,
      # since it was updated on the main process and this function is running from the subprocess.
      #
      # In the future, if we want to support multi processes reporting images with the same title/series,
      # we should move the _count & _filename selection into the subprocess, not the main process.
      # For the time being, this will remain a limitation of the Image reporting mechanism.
  
      if isinstance(self._image_data, (six.StringIO, six.BytesIO)):
          output = self._image_data
      elif self._image_data is not None:
          image_data = self._image_data
          if not isinstance(image_data, np.ndarray):
              # try conversion, if it fails we'll leave it to the user.
              image_data = np.ndarray(image_data, dtype=np.uint8)
          image_data = np.atleast_3d(image_data)
          if image_data.dtype != np.uint8:
              if (
                  np.issubdtype(image_data.dtype, np.floating)
                  and image_data.max() <= 1.0
              ):
                  image_data = (image_data * 255).astype(np.uint8)
              else:
                  image_data = image_data.astype(np.uint8)
          shape = image_data.shape
          height, width, channel = shape[:3]
          if channel == 1:
              image_data = np.reshape(image_data, (height, width))
  
          # serialize image
          image = Image.fromarray(image_data)
          output = six.BytesIO()
          image_format = Image.registered_extensions().get(
              str(self._format).lower(), "JPEG"
          )
          image.save(
              output, format=image_format, quality=int(self._quality)
          )
          output.seek(0)
      else:
          # noinspection PyBroadException
          try:
              output = pathlib2.Path(self._local_image_path)
              if output.is_file():
                  local_file = output
              else:
                  output = None
          except Exception:
              output = None
  
          if output is None:
              LoggerRoot.get_base_logger().warning(
                  "Skipping upload, could not find object file '{}'".format(
                      self._local_image_path
                  )
              )
              return None
  
      return self.FileEntry(
          event=self,
          name=self._upload_filename,
          stream=output,
          url_prop="url",
          key_prop="key",
          upload_uri=self._upload_uri,
          delete_local_file=local_file
          if self._delete_after_upload
          else None,
          retries=self.retries,
      )
  
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 7 for calling the UploadEvent obj's underlying member method code with example usage: obj.get_file_entry() and returns: self, None