Convert obj into Objective class.

  Strings of the form "layer:n" become the Objective channel(layer, n).
  Objectives are returned unchanged.

  Args:
    obj: string or Objective.

  Returns:
    Objective

def as_objective(obj):
  """Convert obj into Objective class.

  Strings of the form "layer:n" become the Objective channel(layer, n).
  Objectives are returned unchanged.

  Args:
    obj: string or Objective.

  Returns:
    Objective
  """
  if isinstance(obj, Objective):
    return obj
  elif callable(obj):
    return obj
  elif isinstance(obj, str):
    layer, n = obj.split(":")
    layer, n = layer.strip(), int(n)
    return channel(layer, n)