Why do we need to set local_rank = int(os.environ["LOCAL_RANK"]) in torchrun?

I saw that we need to do:

local_rank = int(os.environ["LOCAL_RANK"])

but we never set that env variable ourselfs which seems odd. Does torchrun or torch.distributed.launch set it by itself?