class_docstr: Applies RandomErasing to a video.
  
  
  Reference: https://arxiv.org/abs/1708.04896
class_docstr_tok: ["Applies","RandomErasing","to","a","video",".","Reference",":","https",":","\/\/arxiv.org\/abs\/1708.04896"]
docstr: Erase an area.
docstr_tok: ["Erase","an","area","."]
code: def _erase(self, video: tf.Tensor) -> tf.Tensor:
      """Erase an area."""
      if self._min_count == self._max_count:
          count = self._min_count
      else:
          count = tf.random.uniform(
              shape=[],
              minval=int(self._min_count),
              maxval=int(self._max_count - self._min_count + 1),
              dtype=tf.int32,
          )
  
      image_height = tf.shape(video)[1]
      image_width = tf.shape(video)[2]
      area = tf.cast(image_width * image_height, tf.float32)
  
      for _ in range(count):
          # Work around since break is not supported in tf.function
          is_trial_successfull = False
          for _ in range(self._trials):
              if not is_trial_successfull:
                  erase_area = tf.random.uniform(
                      shape=[],
                      minval=area * self._min_area,
                      maxval=area * self._max_area,
                  )
                  aspect_ratio = tf.math.exp(
                      tf.random.uniform(
                          shape=[],
                          minval=self._min_log_aspect,
                          maxval=self._max_log_aspect,
                      )
                  )
  
                  half_height = tf.cast(
                      tf.math.round(
                          tf.math.sqrt(erase_area * aspect_ratio) / 2
                      ),
                      dtype=tf.int32,
                  )
                  half_width = tf.cast(
                      tf.math.round(
                          tf.math.sqrt(erase_area / aspect_ratio) / 2
                      ),
                      dtype=tf.int32,
                  )
  
                  if (
                      2 * half_height < image_height
                      and 2 * half_width < image_width
                  ):
                      center_height = tf.random.uniform(
                          shape=[],
                          minval=0,
                          maxval=int(image_height - 2 * half_height),
                          dtype=tf.int32,
                      )
                      center_width = tf.random.uniform(
                          shape=[],
                          minval=0,
                          maxval=int(image_width - 2 * half_width),
                          dtype=tf.int32,
                      )
  
                      video = _fill_rectangle_video(
                          video,
                          center_width,
                          center_height,
                          half_width,
                          half_height,
                          replace=None,
                      )
  
                      is_trial_successfull = True
      return video
  
imports: import functools
  import math
  from typing import Optional
  from absl import logging
  from dmvr import builders
  from dmvr import processors
  import simclr.tf2.data_util
  import tensorflow
  from official.vision.image_classification import augment
label_desc: Use image node_id 3 for calling the RandomErasing obj's underlying member method code with example usage: obj._erase(video) and returns: video