code: def get_local_rank(
      world_size: Optional[int] = None, rank: Optional[int] = None
  ) -> int:
      """
      Gets the local rank of the local processes (see https://pytorch.org/docs/stable/elastic/run.html)
      This is usually the rank of the worker on its node
      """
      my_local_rank = _env2int(
          [
              "LOCAL_RANK",
              "MPI_LOCALRANKID",
              "OMPI_COMM_WORLD_LOCAL_RANK",
              "MV2_COMM_WORLD_LOCAL_RANK",
          ],
          -1,
      )
      local_size = get_local_size(world_size)
  
      if my_local_rank == -1 or my_local_rank >= local_size:
          logging.warning(
              "Could not determine LOCAL_RANK from environment, falling back to GLOBAL_RANK % LOCAL_SIZE."
          )
          if rank is None:
              rank = dist.get_rank()
          my_local_rank = rank % local_size
      return my_local_rank
  
file_path: torchrec/torchrec/distributed/comm.py
imports: import logging
  import os
  from typing import List, Optional, Tuple
  import torch
  import torch.distributed
label_desc: Use image node_id 3 for calling a global function with example usage: get_local_rank(world_size, rank) and returns: my_local_rank