code: def _check_device(tensor, expected=None):
      if not device.canonical_name(tensor.device):
          raise ValueError(
              f"Device assignment for tensor={tensor} required for nccl "
              "collective ops"
          )
      if expected and expected != tensor.device:
          raise ValueError(
              f"Expected device {expected}, got {tensor.device} for "
              f"tensor={tensor}."
          )
  
file_path: tensorflow/tensorflow/python/ops/nccl_ops.py
imports: import threading
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import device
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import gen_nccl_ops
label_desc: Use image node_id 13 for calling a global function with example usage: _check_device(tensor, expected) without return types