It took me some times to understand what and how this fct does. Can you add a docstring to explain it for the future? Something alone the line:

"""
This function is only used to determine the broardcast pattern for AdvancedSubtensor output variable.

For this, we make a fake ndarray and a fake idx and call use ask numpy the output. From this, we find the output broadcast pattern.
"""