Here's the general approach:

 #!/bin/bash
 out_file=$(basename "$0")
 echo sbatch --gpus=1 -p long -o err_${out_file%.*}.out

If that outputs the `sbatch` command you're trying for, then remove the `echo` and give it a try.

A couple of comments:

 - 99% of the time you don't want a shell that's running your script to behave as a login shell, so I removed the `-l` option from the top line.
 - The `$( ... )` method of capturing the output of a command is usually better than the old-style method that uses backticks/backquotes. There are many fewer problems with special characters and nesting one capture within another.
 - You had the right idea about how to strip trailing characters from the `$out_file` variable, I didn't test your expression, I replaced it with this one, which is somewhat simpler.