code: def patch_aml_env_for_torch_nccl_backend(
      master_port=6105, verbose=True
  ):
      """Helper routine to get and set environment variables.
      This is adapted from Azure ML's documentation available from:
      https://azure.github.io/azureml-web/docs/cheatsheet/distributed-training/#environment-variables-from-openmpi
      """
      os.environ["RANK"] = os.environ["OMPI_COMM_WORLD_RANK"]
      os.environ["WORLD_SIZE"] = os.environ["OMPI_COMM_WORLD_SIZE"]
      single_node = int(
          os.environ["OMPI_COMM_WORLD_LOCAL_SIZE"]
      ) == int(os.environ["WORLD_SIZE"])
  
      if not single_node:
          master_node_params = os.environ["AZ_BATCH_MASTER_NODE"].split(
              ":"
          )
          os.environ["MASTER_ADDR"] = master_node_params[0]
          # Do not overwrite master port with that defined in AZ_BATCH_MASTER_NODE
          if "MASTER_PORT" not in os.environ:
              os.environ["MASTER_PORT"] = str(master_port)
      else:
          os.environ["MASTER_ADDR"] = os.environ[
              "AZ_BATCHAI_MPI_MASTER_NODE"
          ]
          os.environ["MASTER_PORT"] = DEFAULT_AML_MASTER_PORT
  
      if verbose:
          utils.logger.info(
              "NCCL_SOCKET_IFNAME original value = {}".format(
                  os.environ["NCCL_SOCKET_IFNAME"]
              )
          )
  
      os.environ["NCCL_SOCKET_IFNAME"] = DEFAULT_AML_NCCL_SOCKET_IFNAME
      os.environ["LOCAL_RANK"] = os.environ[
          "OMPI_COMM_WORLD_LOCAL_RANK"
      ]
  
      if verbose:
          utils.logger.info(
              "Discovered AzureML settings of world_rank={}, local_rank={}, world_size={}, master_addr={}, master_port={}".format(
                  os.environ["RANK"],
                  os.environ["LOCAL_RANK"],
                  os.environ["WORLD_SIZE"],
                  os.environ["MASTER_ADDR"],
                  os.environ["MASTER_PORT"],
              )
          )
  
imports: import torch
  import os
  from ..constants import TORCH_DISTRIBUTED_DEFAULT_PORT, default_pg_timeout
  from .constants import *
  from .reduce_op import *
  from deepspeed.accelerator import get_accelerator
  from deepspeed.comm.ccl import CCLBackend
  from deepspeed.utils.comms_logging import CommsLogger
  from deepspeed.utils import timer, get_caller_func
  from deepspeed.comm.torch import TorchBackend
  from deepspeed import utils
  from datetime import timedelta
  from deepspeed.comm.utils import *
label_desc: Use image node_id 48 for calling a global function with example usage: patch_aml_env_for_torch_nccl_backend(master_port, verbose) without return types