                      memory[1][:] = exp_result
  
          # Consumer side
          batch_size = 64
          dispatcher = FixedProducerDispatcher(do_work, shapes=[
              (batch_size, 256,256,3), (batch_size, 256,256,3)])
          for batch_wrapper in dispatcher:
              # alternative batch_wrapper.get and batch_wrapper.free can be used
              with batch_wrapper as batch:
                  send_batch_to_trainer(batch)
      """
 
</s> remove         if swap:
            model = self.predictors["a"]
        else:
            model = self.predictors["b"]
 </s> add         side = "a" if swap else "b"
        model = self.predictors[side] </s> remove         coverage = self.get_coverage(image)
 </s> add         coverage = self.get_coverage(image) // 2 </s> remove     Calculates the first and second order gradient difference between pixels of an image in the
    x and y dimensions. These gradients are then compared between the ground truth and the
    predicted image and the difference is taken. The difference used is a smooth L1 norm
    (approximate to MAE but differable at zero) When used as a loss, its minimization will result
    in predicted images approaching the samelevel of sharpness / blurriness as the ground truth.
 </s> add     Calculates the first and second order gradient difference between pixels of
    an image in the x and y dimensions. These gradients are then compared between
    the ground truth and the predicted image and the difference is taken. When
    used as a loss, its minimization will result in predicted images approaching
    the same level of sharpness / blurriness as the ground truth. </s> remove     true_edge_mag = scharr_edges(y_true, True)
    pred_edge_mag = scharr_edges(y_pred, True)
    cnst = 0.002
    upper = 2.0 * tf.multiply(true_edge_mag, pred_edge_mag) + cnst
    lower = tf.square(true_edge_mag) + tf.square(pred_edge_mag) + cnst
    gms = tf.div(upper, lower)
    _mean, _var = tf.nn.moments(gms, axes=[1, 2], keep_dims=True)
    # single metric value per image in tensor [?, 1, 1]
    gmsd = tf.reduce_mean(tf.sqrt(_var), axis=-1)
    # need to expand to [?, height, width] dimensions for Keras ... modify to not be hard-coded
    return K.tile(gmsd, [1, 64, 64])


def ms_ssim(img1, img2, max_val=1.0, power_factors=(0.0517, 0.3295, 0.3462, 0.2726)):
 </s> add     true_edge = scharr_edges(y_true, True)
    pred_edge = scharr_edges(y_pred, True)
    ephsilon = 0.0025
    upper = 2.0 * true_edge * pred_edge
    lower = K.square(true_edge) + K.square(pred_edge)
    gms = (upper + ephsilon) / (lower + ephsilon)
    gmsd = K.std(gms, axis=(1, 2, 3), keepdims=True)
    gmsd = K.squeeze(gmsd, axis=-1)
    return gmsd


def ms_ssim_calc(img1, img2, max_val=1.0, power_factors=(0.0517, 0.3295, 0.3462, 0.2726)): </s> remove                 flat_imgs = [tf.reshape(x, tf.concat([[-1], t], 0))
                             for x, t in zip(imgs, tails)]

 </s> add                 zipped = zip(imgs, tails)
                flat_imgs = [tf.reshape(x, tf.concat([[-1], t], 0)) for x, t in zipped]
        height = width = 256
        batch_shapes = (batch_size, height, width, 3)
        dispatcher = FixedProducerDispatcher(do_work, shapes=[batch_shapes, batch_shapes])
                      memory[1][:] = exp_result
  
          # Consumer side
          batch_size = 64
        height = width = 256
        batch_shapes = (batch_size, height, width, 3)
        dispatcher = FixedProducerDispatcher(do_work, shapes=[batch_shapes, batch_shapes])
        height = width = 256
        batch_shapes = (batch_size, height, width, 3)
        dispatcher = FixedProducerDispatcher(do_work, shapes=[batch_shapes, batch_shapes])
          for batch_wrapper in dispatcher:
              # alternative batch_wrapper.get and batch_wrapper.free can be used
              with batch_wrapper as batch:
                  send_batch_to_trainer(batch)
      """
keep keep keep keep replace replace keep keep keep keep keep
 documentation, pep8, style, clarity updates  - Prep for Segmentation (#812)

* documentation, pep8, style, clarity updates

* Update cli.py

* Update _config.py

remove extra mask and coverage

mask type as dropdown

* Update training_data.py

move coverage / LR to global
cut down on loss description

style change
losses working in PR

* simpler logging

* legacy update 
lib/multithreading.py