class_docstr: Image event adapter 
class_docstr_tok: ["Image","event","adapter"]
code: def _generate_file_name(self, force_pid_suffix=None):
      if force_pid_suffix is None and self._filename is not None:
          return
  
      self._count = self._get_metric_count(self._metric, self._variant)
  
      self._filename = self._override_filename
      if not self._filename:
          self._filename = "{}_{}".format(self._metric, self._variant)
          cnt = (
              self._count
              if self.file_history_size < 1
              else (self._count % self.file_history_size)
          )
          self._filename += (
              "_{:05x}{:03d}".format(force_pid_suffix, cnt)
              if force_pid_suffix
              else "_{:08d}".format(cnt)
          )
  
      # make sure we have to '/' in the filename because it might access other folders,
      # and we don't want that to occur
      self._filename = self._replace_slash(self._filename)
  
      # get upload uri upfront, either predefined image format or local file extension
      # e.g.: image.png -> .png or image.raw.gz -> .raw.gz
      filename_ext = self._override_filename_ext
      if filename_ext is None:
          filename_ext = (
              str(self._format).lower()
              if self._image_data is not None
              else "."
              + ".".join(
                  pathlib2.Path(self._local_image_path)
                  .parts[-1]
                  .split(".")[1:]
              )
          )
      # always add file extension to the uploaded target file
      if filename_ext and filename_ext[0] != ".":
          filename_ext = "." + filename_ext
      self._upload_filename = pathlib2.Path(self._filename).as_posix()
      if (
          self._filename.rpartition(".")[2]
          != filename_ext.rpartition(".")[2]
      ):
          self._upload_filename += filename_ext
  
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 3 for calling the UploadEvent obj's underlying member method code with example usage: obj._generate_file_name(force_pid_suffix) without return types