def sampled_sequence_loss(inputs, targets, weights, loss_function, average_across_timesteps=True, average_across_batch=True, name=None):
 with tf.op_scope(((inputs + targets) + weights), name, 'sampled_sequence_loss'):
  cost = tf.reduce_sum(sequence_loss_by_example(inputs, targets, weights, loss_function, average_across_timesteps=average_across_timesteps))
  if average_across_batch:
   batch_size = tf.shape(targets[0])[0]
   return (cost / tf.cast(batch_size, tf.float32))
  else:
   return cost

def sampled_sequence_loss ( inputs , targets , weights , loss_function , average_across_timesteps = True , average_across_batch = True , name = None ) : with tf . op_scope ( ( ( inputs + targets ) + weights ) , name , 'sampled_sequence_loss' ) : cost = tf . reduce_sum ( sequence_loss_by_example ( inputs , targets , weights , loss_function , average_across_timesteps = average_across_timesteps ) ) if average_across_batch : batch_size = tf . shape ( targets [ 0 ] ) [ 0 ] return ( cost / tf . cast ( batch_size , tf . float32 ) ) else : return cost
weighted cross-entropy loss for a sequence of logits .