If I understand your use case correctly, each index in __getitem__ would load 9 samples and the corresponding 9 targets (9 would be the sequence length).
If that’s the case, you would need to create a weight value for each sample, not each value in the sequence.
The first approach seems to create sample_weight in the shape [nb_samples, seq_len], while the latter would flatten it.
Note that the sampler yields the index values, which are passed to the __getitem__, so it would have nb_samples weight values.