(inputs_BxI, targets_BxT, bucket_size, bucket_start_id,
                         max_num_buckets)
return inputs_BxI
Add bucket id of the target to start of the inputs.
Add bucket id of the target to start of the inputs.
Add bucket id of the target to start of the inputs .
def add_length_bucket_id(inputs_BxI, targets_BxT, bucket_size, bucket_start_id,
                         max_num_buckets):
  """Add bucket id of the target to start of the inputs."""
  if bucket_size:
    non_pad_BxL = tf.cast(tf.greater(targets_BxT, 0), targets_BxT.dtype)
    length_Bx1 = tf.reduce_sum(non_pad_BxL, axis=-1, keep_dims=True)
    bucket_id_Bx1 = length_Bx1 // bucket_size + bucket_start_id
    # tail distributions are assigned to the last bucket.
    bucket_id_Bx1 = tf.minimum(bucket_id_Bx1, max_num_buckets)
    inputs_BxI = tf.concat([bucket_id_Bx1, inputs_BxI[:, :-1]], axis=-1)
  return inputs_BxI
def add_length_bucket_id ( inputs_BxI , targets_BxT , bucket_size , bucket_start_id , max_num_buckets ) : if bucket_size : non_pad_BxL = tf . cast ( tf . greater ( targets_BxT , 0 ) , targets_BxT . dtype ) length_Bx1 = tf . reduce_sum ( non_pad_BxL , axis = - 1 , keep_dims = True ) bucket_id_Bx1 = length_Bx1 // bucket_size + bucket_start_id # tail distributions are assigned to the last bucket. bucket_id_Bx1 = tf . minimum ( bucket_id_Bx1 , max_num_buckets ) inputs_BxI = tf . concat ( [ bucket_id_Bx1 , inputs_BxI [ : , : - 1 ] ] , axis = - 1 ) return inputs_BxI