code: def get_weighted_sampler(
      sample_weights: List[float],
      batch_size: int,
      world_size: int,
      num_steps: int,
  ) -> torch.utils.data.WeightedRandomSampler:
      """
      Create pytorch sampler for doing weighted random sampling.
  
      Args:
          sample_weights: List of sampling weights for all elements in the dataset.
          batch_size: Batch size to sample.
          world_size: Number of devices being used.
          num_steps: Number of steps to be considered an epoch.
  
      Returns:
          Pytorch sampler
      """
      weights = torch.tensor(sample_weights, dtype=torch.float64)
      num_samples = batch_size * world_size * num_steps
      sampler = torch.utils.data.WeightedRandomSampler(
          weights=weights, num_samples=num_samples
      )
      return sampler
  
imports: import functools
  import os
  import random
  import traceback
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple
  import librosa
  import numpy
  import torch
  from einops import rearrange
  from scipy import ndimage
  from torch.special import gammaln
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
label_desc: Use image node_id 12 for calling a global function with example usage: get_weighted_sampler(sample_weights, batch_size, world_size, num_steps) and returns: sampler