code: def get_master_port(real_launcher=False):
      """
      When using a single gpu launcher emulation (i.e. not deepspeed or python -m torch.distributed)
      the issue is that once the port is tied it can't be used anywhere else outside of this process,
      since torch.dist doesn't free the port until the process exits. Therefore for the sake of being
      able to run both emulated launcher and normal launcher tests we need 2 distinct ports.
  
      This function will give the right port in the right context. For real launcher it'll give the
      base port, for emulated launcher it'll give the base port + 1. In both cases a string is
      returned.
  
      Args:
          `real_launcher`: whether a real launcher is going to be used, or the emulated one
  
      """
  
      master_port_base = os.environ.get(
          "DS_TEST_PORT", DEFAULT_MASTER_PORT
      )
      if not real_launcher:
          master_port_base = str(int(master_port_base) + 1)
      return master_port_base
  
imports: import gc
  import os
  import random
  import tempfile
  import unittest
  from itertools import chain
  from typing import List, Optional
  from unittest.mock import Mock, patch
  import nltk
  import numpy
  from datasets import load_dataset
  from evaluate import load
  from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoTokenizer, DataCollatorForSeq2Seq, DataCollatorWithPadding, default_data_collator, is_torch_available
  from transformers.testing_utils import mockenv_context, require_deepspeed, require_torch, slow
  from transformers.training_args import OptimizerNames
  import onnxruntime
  from parameterized import parameterized
  from optimum.onnxruntime import ORTSeq2SeqTrainer, ORTSeq2SeqTrainingArguments, ORTTrainer, ORTTrainingArguments
  from optimum.onnxruntime.training_args import ORTOptimizerNames
label_desc: Use image node_id 4 for calling a global function with example usage: get_master_port(real_launcher) and returns: master_port_base