human
Complete this python program:
def cycle_gan_internal(inputs, targets, _, hparams):
assistant
#Here is the Python program you requested.

    """Cycle GAN, main step used for training.
    """
    with tf.variable_scope('cycle_gan'):
        (inputs_orig, targets_orig) = (tf.to_int32(inputs), tf.to_int32(targets))
        inputs = common_layers.embedding(inputs_orig, hparams.vocab_size, hparams.hidden_size, 'embed')
        targets = common_layers.embedding(targets_orig, hparams.vocab_size, hparams.hidden_size, 'embed', reuse=True)
        (inputs1, _) = split_on_batch(inputs)
        (_, targets2) = split_on_batch(targets)
        def inp2tgt(x, reuse=False):
            return transformer_vae.residual_conv(x, 1, hparams, 'inp2tgt', reuse)
        def tgt2inp(x, reuse=False):
            return transformer_vae.residual_conv(x, 1, hparams, 'tgt2inp', reuse)
        inp1_tgt = inp2tgt(inputs1)
        inp1_back = tgt2inp(inp1_tgt)
        tgt2_inp = tgt2inp(targets2, reuse=True)
        tgt2_back = inp2tgt(tgt2_inp, reuse=True)
        (inp1_orig, _) = split_on_batch(inputs_orig)
        (_, tgt2_orig) = split_on_batch(targets_orig)
        inp1_loss = reconstruct_loss(inp1_back, tf.squeeze(inp1_orig, axis=3), hparams)
        tgt2_loss = reconstruct_loss(tgt2_back, tf.squeeze(tgt2_orig, axis=3), hparams, reuse=True)
        dloss1 = discriminate_loss(inputs1, tgt2_inp, True, hparams, 'inp_disc')
        dloss2 = discriminate_loss(targets2, inp1_tgt, True, hparams, 'tgt_disc')
        tgt = inp2tgt(inputs, reuse=True)
        tgt = tf.layers.dense(tgt, hparams.vocab_size, name='softmax', reuse=True)
        tgt = tf.stop_gradient(tf.expand_dims(tgt, axis=2))
        losses = {'input_input': (hparams.cycle_loss_multiplier * inp1_loss), 'target_target': (hparams.cycle_loss_multiplier * tgt2_loss), 'input_disc': dloss1, 'target_disc': dloss2}
        return (tgt, losses)