from tensorflow.python.framework import ops as _ops

          (self._name, self._shape))
      assert self._send_tpu_core != self._recv_tpu_core, (
          "TPU send/recv must be cross-core: %s and %s" %
          (send_device, recv_device))

  def Send(self, tensor):
    """Sends a tensor through the channel."""
    assert tensor.dtype == self._dtype
    assert not self._send_called, (
        "Send called multiple times for %s" % self._name)
    self._send_called = True
    if self._send_tpu_core == -1:
      return _Send(tensor, self._name, self._send_device, self._recv_device)
    else:
      with _ops.device(self._send_device):
        return _XlaSend(
            tensor, tensor_name=self._name, name="Send_" + self._name)

  def Recv(self):
    """Receives a tensor from the channel."""
    if self._send_tpu_core == -1:
      return _Recv(self._dtype, self._name,
                   self._send_device, self._recv_device)
    else:
      with _ops.device(self._recv_device):
        return _XlaRecv(
            self._dtype,
            tensor_name=self._name,
