class_docstr: Test that SoftmaxCrossEntropyWithLogits operates reproducibly.
  
  Inheriting from xent_op_test_base.XentTestBase ensures that regular op
  functionality is correct when the deterministic code-path is selected.
  
  Note that because nn_ops.softmax_cross_entropy_with_logits calls
  nn_ops.cross_entropy_with_logits_v2, the focus of testing is on the
  former in order to test both.
docstr: Modify testing of gradient for labels-broadcast case.
  
  The deterministic implementation does not produce the gradients expected by
  the original test (for the nondeterministic functionality) when the labels
  vector (after broadcasting) is not a valid probability distribution.
  
  labels: [[0.], [2.], [0.25]]
  logits: [[1., 1., 1., 1.],
           [1., 2., 3., 4.],
           [1., 2., 3., 4.]]
  
  dloss/dlogits (nondeterministic):
      [[ 0.25 ,  0.25 ,  0.25 ,  0.25 ],
       [-1.968, -1.913, -1.763, -1.355],
       [-0.218, -0.163, -0.013,  0.394]]
  
  dloss/dlogits (determinsitic):
      [[ 0.   ,  0.   ,  0.   ,  0.   ],
       [-1.743, -1.303, -0.105,  3.150],
       [-0.218, -0.163, -0.013,  0.394]]
  
  Note that neither of the first two broadcast label vectors is a valid
  probability distribution (as required by the API) and that these are the
  cases that yield different gradients for nondeterministic vs determinsitic
  implementations.
  
  TODO(duncanriach): Further investigate the source of the difference in
                     the gradient for this case.
docstr_tok: ["Modify","testing","of","gradient","for","labels-broadcast","case",".","The","deterministic","implementation","does","not","produce","the","gradients","expected","by","the","original","test","(","for","the","nondeterministic","functionality",")","when","the","labels","vector","(","after","broadcasting",")","is","not","a","valid","probability","distribution",".","labels",":","[","[","0",".","]",",","[","2",".","]",",","[","0.25","]","]","logits",":","[","[","1.",",","1.",",","1.",",","1",".","]",",","[","1.",",","2.",",","3.",",","4",".","]",",","[","1.",",","2.",",","3.",",","4",".","]","]","dloss\/dlogits","(","nondeterministic",")",":","[","[","0.25",",","0.25",",","0.25",",","0.25","]",",","[","-1.968",",","-1.913",",","-1.763",",","-1.355","]",",","[","-0.218",",","-0.163",",","-0.013",",","0.394","]","]","dloss\/dlogits","(","determinsitic",")",":","[","[","0.",",","0.",",","0.",",","0",".","]",",","[","-1.743",",","-1.303",",","-0.105",",","3.150","]",",","[","-0.218",",","-0.163",",","-0.013",",","0.394","]","]","Note","that","neither","of","the","first","two","broadcast","label","vectors","is","a","valid","probability","distribution","(","as","required","by","the","API",")","and","that","these","are","the","cases","that","yield","different","gradients","for","nondeterministic","vs","determinsitic","implementations",".","TODO","(","duncanriach",")",":","Further","investigate","the","source","of","the","difference","in","the","gradient","for","this","case","."]
code: def testLabelsBroadcast(self):
      """Modify testing of gradient for labels-broadcast case.
  
      The deterministic implementation does not produce the gradients expected by
      the original test (for the nondeterministic functionality) when the labels
      vector (after broadcasting) is not a valid probability distribution.
  
      labels: [[0.], [2.], [0.25]]
      logits: [[1., 1., 1., 1.],
               [1., 2., 3., 4.],
               [1., 2., 3., 4.]]
  
      dloss/dlogits (nondeterministic):
          [[ 0.25 ,  0.25 ,  0.25 ,  0.25 ],
           [-1.968, -1.913, -1.763, -1.355],
           [-0.218, -0.163, -0.013,  0.394]]
  
      dloss/dlogits (determinsitic):
          [[ 0.   ,  0.   ,  0.   ,  0.   ],
           [-1.743, -1.303, -0.105,  3.150],
           [-0.218, -0.163, -0.013,  0.394]]
  
      Note that neither of the first two broadcast label vectors is a valid
      probability distribution (as required by the API) and that these are the
      cases that yield different gradients for nondeterministic vs determinsitic
      implementations.
  
      TODO(duncanriach): Further investigate the source of the difference in
                         the gradient for this case.
      """
      self._testLabelsBroadcast(
          uniform_labels_gradient=[
              [0.0, 0.0, 0.0, 0.0],
              [-1.743, -1.303, -0.105, 3.150],
              [-0.218, -0.163, -0.013, 0.394],
          ]
      )
  
imports: import numpy
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.nn_ops import xent_op_test_base
  from tensorflow.python.ops import gen_nn_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops.nn_grad import _SoftmaxCrossEntropyWithLogitsGrad
  from tensorflow.python.platform import test
label_desc: Use image node_id 6 for calling the XentOpDeterministicTest obj's underlying member method code with example usage: obj.testLabelsBroadcast() without return types