<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setup(self, target_directory=None):
 # pylint: disable=arguments-differ """Sets up the _target_directory attribute. Args: target_directory: Directory in which collected files will be dumped. """

    self._target_directory = target_directory
    if not target_directory:
      self._target_directory = tempfile.mkdtemp()
    elif not os.path.exists(target_directory):
      try:
        os.makedirs(target_directory)
      except OSError as exception:
        message = 'An unknown error occurred: {0!s}'.format(exception)
        self.state.add_error(message, critical=True)