code: def get_local_size(world_size: Optional[int] = None) -> int:
      if world_size is None:
          world_size = dist.get_world_size()
      """
      Gets the local world size (see https://pytorch.org/docs/stable/elastic/run.html)
      This is usually the size of workers on each node, or nproc_per_node
      """
      local_size = _env2int(
          [
              "LOCAL_WORLD_SIZE",
              "MPI_LOCALNRANKS",
              "OMPI_COMM_WORLD_LOCAL_SIZE",
              "MV2_COMM_WORLD_LOCAL_SIZE",
          ],
          8,
      )
  
      if local_size == -1 or world_size % local_size != 0:
          logging.warning(
              "Could not determine LOCAL_WORLD_SIZE from environment, falling back to WORLD_SIZE."
          )
          local_size = world_size
      return local_size
  
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 2 for calling a global function with example usage: get_local_size(world_size) and returns: local_size