code: def get_batch_size_from_opts(
      opts: argparse.Namespace, is_training: bool = False
  ) -> int:
      """Helper function to extract batch size for training or validation/test
  
      Args:
          opts: command line argument
          is_training: Training or validation mode. Default: False
  
      Returns:
          Returns an integer
      """
      batch_size_gpu0 = int(
          getattr(opts, "dataset.train_batch_size0")
          if is_training
          else getattr(opts, "dataset.val_batch_size0")
      )
      return batch_size_gpu0
  
imports: import argparse
  import copy
  import math
  import random
  from typing import Any, Iterator, List, Tuple
  import numpy
  import torch
  import torch.distributed
  from torch.utils.data.sampler import Sampler
label_desc: Use image node_id 1 for calling a global function with example usage: get_batch_size_from_opts(opts, is_training) and returns: batch_size_gpu0