code: def _sample_parameters(size, scale_ratio_range, aspect_ratio_range):
      H, W = size
      for _ in range(10):
          aspect_ratio = random.uniform(
              aspect_ratio_range[0], aspect_ratio_range[1]
          )
          if random.uniform(0, 1) < 0.5:
              aspect_ratio = 1 / aspect_ratio
          # This is determined so that relationships "H - H_crop >= 0" and
          # "W - W_crop >= 0" are always satisfied.
          scale_ratio_max = min(
              (
                  scale_ratio_range[1],
                  H / (W * aspect_ratio),
                  (aspect_ratio * W) / H,
              )
          )
  
          scale_ratio = random.uniform(
              scale_ratio_range[0], scale_ratio_range[1]
          )
          if scale_ratio_range[0] <= scale_ratio <= scale_ratio_max:
              return scale_ratio, aspect_ratio
  
      # This scale_ratio is outside the given range when
      # scale_ratio_max < scale_ratio_range[0].
      scale_ratio = random.uniform(
          min((scale_ratio_range[0], scale_ratio_max)), scale_ratio_max
      )
      return scale_ratio, aspect_ratio
  
imports: from __future__ import division
  import math
  import numpy
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: _sample_parameters(size, scale_ratio_range, aspect_ratio_range) and returns: scale_ratio,  aspect_ratio, scale_ratio,  aspect_ratio