keras/src/backend/tensorflow/trainer.py/_is_per_replica_instance
def _is_per_replica_instance(obj):
    return isinstance(obj, tf.distribute.DistributedValues) and isinstance(
        obj, tf.__internal__.CompositeTensor
    )