<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def penalize_boundary_complexity(shp, w=20, mask=None, C=0.5):
 """Encourage the boundaries of an image to have less variation and of color C. Args: shp: shape of T("input") because this may not be known. w: width of boundary to penalize. Ignored if mask is set. mask: mask describing what area should be penalized. Returns: Objective. """

  def inner(T):
    arr = T("input")

    # print shp
    if mask is None:
      mask_ = np.ones(shp)
      mask_[:, w:-w, w:-w] = 0
    else:
      mask_ = mask

    blur = _tf_blur(arr, w=5)
    diffs = (blur-arr)**2
    diffs += 0.8*(arr-C)**2

    return -tf.reduce_sum(diffs*mask_)
  return inner