I’m not sure, how you are calling xavier_init, but if ms is a module, the for loop will throw this error.
Your current code (net.weight_init()) is not passing any arguments, and xavier_init is not defined as a class function.