class_docstr: Sample frames id.
  NOTE: Use PIL to read image here, has diff with CV2
  Args:
      num_seg(int): number of segments.
      seg_len(int): number of sampled frames in each segment.
      valid_mode(bool): True or False.
  Returns:
      frames_idx: the index of sampled #frames.
class_docstr_tok: ["Sample","frames","id",".","NOTE",":","Use","PIL","to","read","image","here",",","has","diff","with","CV2","Args",":","num_seg","(","int",")",":","number","of","segments",".","seg_len","(","int",")",":","number","of","sampled","frames","in","each","segment",".","valid_mode","(","bool",")",":","True","or","False",".","Returns",":","frames_idx",":","the","index","of","sampled","#","frames","."]
code: def _get_train_clips(self, num_frames):
      ori_seg_len = self.seg_len * self.frame_interval
      avg_interval = (num_frames - ori_seg_len + 1) // self.num_seg
  
      if avg_interval > 0:
          base_offsets = np.arange(self.num_seg) * avg_interval
          clip_offsets = base_offsets + np.random.randint(
              avg_interval, size=self.num_seg
          )
      elif num_frames > max(self.num_seg, ori_seg_len):
          clip_offsets = np.sort(
              np.random.randint(
                  num_frames - ori_seg_len + 1, size=self.num_seg
              )
          )
      elif avg_interval == 0:
          ratio = (num_frames - ori_seg_len + 1.0) / self.num_seg
          clip_offsets = np.around(np.arange(self.num_seg) * ratio)
      else:
          clip_offsets = np.zeros((self.num_seg,), dtype=np.int)
      return clip_offsets
  
imports: import cv2
  import numpy
  from PIL import Image
  import paddle
label_desc: Use image node_id 3 for calling the Sampler obj's underlying member method code with example usage: obj._get_train_clips(num_frames) and returns: clip_offsets