EDIT: about checking this and that
This is an approach maintaining an 1:1 relation between the minimal set of valid inputs (0...4535) and valid outputs (the 998*7 possible 4-digit numbers with distinct digits, not-starting-with-0). So a simple loop can generate all the numbers, they can be checked one-by-one and they can be collected into a set for example in order to see if they are all distinct results
Practically:
collect=set()
for rnd in range(0,4536):
(rnd,d1)=divmod(rnd,9)
... rest of the code, also the verification step kept active ...
collect.add(val)
print(len(collect))
It will not print anything in the loop (all results are 4-digit numbers with distinct digits)
It will print 4536 at the end (all results are distinct)
One can add a verification for the first digit (d1), here and now I just assume that
"(something mod 9)+1" will not be 0.