def GetTensorOpName(x):
  """Get the name of the op that created a tensor. Useful for naming related
  tensors, as ':' in name field of op is not permitted.

  Args:
    x: the input tensor.

  Returns:
    the name of the op.
  """

  t = x.name.rsplit(":", 1)
  if len(t) == 1:
    return x.name
  else:
    return t[0]