class_docstr: Match texts model with Match Pyramid.
class_docstr_tok: ["Match","texts","model","with","Match","Pyramid","."]
code: def _dynamic_pooling_index(
      self,
      length_left,
      length_right,
      fixed_length_left: int,
      fixed_length_right: int,
      compress_ratio_left: float,
      compress_ratio_right: float,
  ) -> tf.Tensor:
      def _dpool_index(
          one_length_left,
          one_length_right,
          fixed_length_left,
          fixed_length_right,
      ):
          logging.info(
              "fixed_length_left: {}".format(fixed_length_left)
          )
          logging.info(
              "fixed_length_right: {}".format(fixed_length_right)
          )
  
          if one_length_left == 0:
              stride_left = fixed_length_left
          else:
              stride_left = (
                  1.0
                  * fixed_length_left
                  / tf.cast(one_length_left, dtype=tf.float32)
              )
  
          if one_length_right == 0:
              stride_right = fixed_length_right
          else:
              stride_right = (
                  1.0
                  * fixed_length_right
                  / tf.cast(one_length_right, dtype=tf.float32)
              )
  
          one_idx_left = [
              tf.cast(i / stride_left, dtype=tf.int32)
              for i in range(fixed_length_left)
          ]
          one_idx_right = [
              tf.cast(i / stride_right, dtype=tf.int32)
              for i in range(fixed_length_right)
          ]
          mesh1, mesh2 = tf.meshgrid(one_idx_left, one_idx_right)
          index_one = tf.transpose(tf.stack([mesh1, mesh2]), (2, 1, 0))
          return index_one
  
      index = []
      dpool_bias_left = dpool_bias_right = 0
      if fixed_length_left % compress_ratio_left != 0:
          dpool_bias_left = 1
      if fixed_length_right % compress_ratio_right != 0:
          dpool_bias_right = 1
      cur_fixed_length_left = (
          int(fixed_length_left // compress_ratio_left)
          + dpool_bias_left
      )
      cur_fixed_length_right = (
          int(fixed_length_right // compress_ratio_right)
          + dpool_bias_right
      )
      logging.info("length_left: {}".format(length_left))
      logging.info("length_right: {}".format(length_right))
      logging.info(
          "cur_fixed_length_left: {}".format(cur_fixed_length_left)
      )
      logging.info(
          "cur_fixed_length_right: {}".format(cur_fixed_length_right)
      )
  
      index = tf.map_fn(
          lambda x: _dpool_index(
              x[0], x[1], cur_fixed_length_left, cur_fixed_length_right
          ),
          (length_left, length_right),
          dtype=tf.int32,
      )
  
      logging.info("index: {}".format(index))
  
      return index
  
file_path: delta/delta/models/text_match_model.py
imports: import pickle
  from absl import logging
  import delta.compat
  from delta.layers.dynamic_pooling import DynamicPoolingLayer
  from delta.layers.match_pyramid import MatchingLayer
  from delta.models.base_model import Model
  from delta.utils.register import registers
label_desc: Use image node_id 3 for calling the MatchPyramidTextClassModel obj's underlying member method code with example usage: obj._dynamic_pooling_index(length_left, length_right, fixed_length_left, fixed_length_right, compress_ratio_left, compress_ratio_right) and returns: index, index_one