code: def huber_loss(tensor, k=1, scope=None):
      
      # assert k >= 0
      with tf.name_scope(scope, 'L1Loss', [tensor]):
          loss = tf.reduce_mean(tf.select(tf.abs(tensor) < k,
                                          0.5 * tf.square(tensor),
                                          k * tf.abs(tensor) - 0.5 * k ^ 2)
                                )
          return loss
docs: Define a huber loss  https://en.wikipedia.org/wiki/Huber_loss 
        tensor: tensor to regularize.
        k: value of k in the huber loss
        scope: Optional scope for op_scope.
  
      Huber loss:
      f(x) = if |x| <= k:
                0.5 * x^2
             else:
                k * |x| - 0.5 * k^2
  
      Returns:
        the L1 loss op.