class_docstr: Truncates a list of segments using a pre-determined truncation strategy.
class_docstr_tok: ["Truncates","a","list","of","segments","using","a","pre-determined","truncation","strategy","."]
docstr: Truncate the list of `segments`.
  
  Truncate the list of `segments` using the truncation strategy defined by
  `generate_mask`.
  
  Args:
    segments: A list of `RaggedTensor`s w/ shape [num_batch, (num_items)].
  
  Returns:
    a list of `RaggedTensor`s with len(segments) number of items and where
    each item has the same shape as its counterpart in `segments` and
    with unwanted values dropped. The values are dropped according to the
    `TruncationStrategy` defined.
docstr_tok: ["Truncate","the","list","of","`","segments","`",".","Truncate","the","list","of","`","segments","`","using","the","truncation","strategy","defined","by","`","generate_mask","`",".","Args",":","segments",":","A","list","of","`","RaggedTensor","`","s","w\/","shape","[","num_batch",",","(","num_items",")","]",".","Returns",":","a","list","of","`","RaggedTensor","`","s","with","len","(","segments",")","number","of","items","and","where","each","item","has","the","same","shape","as","its","counterpart","in","`","segments","`","and","with","unwanted","values","dropped",".","The","values","are","dropped","according","to","the","`","TruncationStrategy","`","defined","."]
code: def trim(self, segments):
      """Truncate the list of `segments`.
  
      Truncate the list of `segments` using the truncation strategy defined by
      `generate_mask`.
  
      Args:
        segments: A list of `RaggedTensor`s w/ shape [num_batch, (num_items)].
  
      Returns:
        a list of `RaggedTensor`s with len(segments) number of items and where
        each item has the same shape as its counterpart in `segments` and
        with unwanted values dropped. The values are dropped according to the
        `TruncationStrategy` defined.
      """
      with ops.name_scope("Trimmer/Trim"):
          segments = [
              ragged_tensor.convert_to_tensor_or_ragged_tensor(s)
              for s in segments
          ]
          truncate_masks = self.generate_mask(segments)
          truncated_segments = [
              ragged_array_ops.boolean_mask(
                  seg, mask.with_row_splits_dtype(seg.row_splits.dtype)
              )
              for seg, mask in zip(segments, truncate_masks)
          ]
          return truncated_segments
  
imports: import abc
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow_text.python.ops import item_selector_ops
  from tensorflow.python.framework import load_library
  from tensorflow.python.platform import resource_loader
  from tensorflow.python.ops import while_loop
label_desc: Use image node_id 1 for calling the Trimmer obj's underlying member method code with example usage: obj.trim(segments) and returns: truncated_segments