<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def perform(self):
 """This method converts payload into args and calls the ``perform`` method on the payload class. Before calling ``perform``, a ``before_perform`` class method is called, if it exists. It takes a dictionary as an argument; currently the only things stored on the dictionary are the args passed into ``perform`` and a timestamp of when the job was enqueued. Similarly, an ``after_perform`` class method is called after ``perform`` is finished. The metadata dictionary contains the same data, plus a timestamp of when the job was performed, a ``failed`` boolean value, and if it did fail, a ``retried`` boolean value. This method is called after retry, and is called regardless of whether an exception is ultimately thrown by the perform method. """

        payload_class_str = self._payload["class"]
        payload_class = self.safe_str_to_class(payload_class_str)
        payload_class.resq = self.resq
        args = self._payload.get("args")

        metadata = dict(args=args)
        if self.enqueue_timestamp:
            metadata["enqueue_timestamp"] = self.enqueue_timestamp

        before_perform = getattr(payload_class, "before_perform", None)

        metadata["failed"] = False
        metadata["perform_timestamp"] = time.time()
        check_after = True
        try:
            if before_perform:
                payload_class.before_perform(metadata)
            return payload_class.perform(*args)
        except Exception as e:
            metadata["failed"] = True
            metadata["exception"] = e
            if not self.retry(payload_class, args):
                metadata["retried"] = False
                raise
            else:
                metadata["retried"] = True
                logging.exception("Retry scheduled after error in %s", self._payload)
        finally:
            after_perform = getattr(payload_class, "after_perform", None)

            if after_perform:
                payload_class.after_perform(metadata)

            delattr(payload_class,'resq')