class_docstr: Base class of Input processor.
class_docstr_tok: ["Base","class","of","Input","processor","."]
docstr: Set the parameters for multiscale training.
  
  Notably, if train and eval use different sizes, then target_size should be
  set as eval size to avoid the discrency between train and eval.
  
  Args:
    scale_min: minimal scale factor.
    scale_max: maximum scale factor.
    target_size: targeted size, usually same as eval. If None, use train size.
docstr_tok: ["Set","the","parameters","for","multiscale","training",".","Notably",",","if","train","and","eval","use","different","sizes",",","then","target_size","should","be","set","as","eval","size","to","avoid","the","discrency","between","train","and","eval",".","Args",":","scale_min",":","minimal","scale","factor",".","scale_max",":","maximum","scale","factor",".","target_size",":","targeted","size",",","usually","same","as","eval",".","If","None",",","use","train","size","."]
code: def set_training_random_scale_factors(
      self, scale_min, scale_max, target_size=None
  ):
      """Set the parameters for multiscale training.
  
      Notably, if train and eval use different sizes, then target_size should be
      set as eval size to avoid the discrency between train and eval.
  
      Args:
        scale_min: minimal scale factor.
        scale_max: maximum scale factor.
        target_size: targeted size, usually same as eval. If None, use train size.
      """
      if not target_size:
          target_size = self._output_size
      target_size = utils.parse_image_size(target_size)
      logging.info(
          "target_size = %s, output_size = %s",
          target_size,
          self._output_size,
      )
  
      # Select a random scale factor.
      random_scale_factor = tf.random.uniform([], scale_min, scale_max)
      scaled_y = tf.cast(random_scale_factor * target_size[0], tf.int32)
      scaled_x = tf.cast(random_scale_factor * target_size[1], tf.int32)
  
      # Recompute the accurate scale_factor using rounded scaled image size.
      height = tf.cast(tf.shape(self._image)[0], tf.float32)
      width = tf.cast(tf.shape(self._image)[1], tf.float32)
      image_scale_y = tf.cast(scaled_y, tf.float32) / height
      image_scale_x = tf.cast(scaled_x, tf.float32) / width
      image_scale = tf.minimum(image_scale_x, image_scale_y)
  
      # Select non-zero random offset (x, y) if scaled image is larger than
      # self._output_size.
      scaled_height = tf.cast(height * image_scale, tf.int32)
      scaled_width = tf.cast(width * image_scale, tf.int32)
      offset_y = tf.cast(
          scaled_height - self._output_size[0], tf.float32
      )
      offset_x = tf.cast(
          scaled_width - self._output_size[1], tf.float32
      )
      offset_y = tf.maximum(0.0, offset_y) * tf.random.uniform([], 0, 1)
      offset_x = tf.maximum(0.0, offset_x) * tf.random.uniform([], 0, 1)
      offset_y = tf.cast(offset_y, tf.int32)
      offset_x = tf.cast(offset_x, tf.int32)
      self._image_scale = image_scale
      self._scaled_height = scaled_height
      self._scaled_width = scaled_width
      self._crop_offset_x = offset_x
      self._crop_offset_y = offset_y
  
imports: from absl import logging
  import tensorflow
  import utils
  from pipeline import anchors
  from .None import preprocessor
  from .None import tf_example_decoder
label_desc: Use image node_id 3 for calling the InputProcessor obj's underlying member method code with example usage: obj.set_training_random_scale_factors(scale_min, scale_max, target_size) without return types