code: def _composite_tensor_from_variant_grad(op, *grad):
      assert len(grad) == len(op.outputs)
      # `components` is `op.outputs`, but with any tensors for which we're
      # taking the gradient replaced by the corresponding value from `grad`.
      components = [
          op.outputs[i] if grad[i] is None else grad[i]
          for i in range(len(grad))
      ]
      return (
          gen_composite_tensor_ops.CompositeTensorVariantFromComponents(
              components=components, metadata=op.get_attr("metadata")
          )
      )
  
file_path: tensorflow/tensorflow/python/ops/composite_tensor_ops.py
imports: from tensorflow.core.protobuf import composite_tensor_variant_pb2
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import gen_composite_tensor_ops
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.util import nest
label_desc: Use image node_id 4 for calling a global function with example usage: _composite_tensor_from_variant_grad(op) and returns: gen_composite_tensor_ops