def variable_ref(t):
  """Find the variable ref, ignoring Identity ops.

  Args:
    t: a Tensor

  Returns:
    a Tensor that is a variable ref, or None on error.
  """
  while t.op.type == "Identity":
    t = t.op.inputs[0]
  if "Variable" in t.op.type:
    return t
  else:
    return None