code: def temp_dir(apply_chown=None, apply_chmod=None, remove_using_sudo=None, remove_force=False):
      
      path = get_remote_temp()
      try:
          if apply_chmod:
              run(chmod(apply_chmod, path))
          if apply_chown:
              if remove_using_sudo is None:
                  remove_using_sudo = True
              sudo(chown(apply_chown, path))
          yield path
      finally:
          remove_ignore(path, use_sudo=remove_using_sudo, force=remove_force)
docs: Creates a temporary directory on the remote machine. The directory is removed when no longer needed. Failure to do
      so will be ignored.
  
      :param apply_chown: Optional; change the owner of the directory.
      :type apply_chown: unicode
      :param apply_chmod: Optional; change the permissions of the directory.
      :type apply_chmod: unicode
      :param remove_using_sudo: Use sudo for removing the directory. ``None`` (default) means it is used depending on
       whether ``apply_chown`` has been set.
      :type remove_using_sudo: bool | NoneType
      :param remove_force: Force the removal.
      :type remove_force: bool
      :return: Path to the temporary directory.
      :rtype: unicode