class_docstr: Test Baidu CTC wrapper implementation.
  
  Expected values for costs and gradients are obtained through an external
  C implementation, that uses the library directly.
class_docstr_tok: ["Test","Baidu","CTC","wrapper","implementation",".","Expected","values","for","costs","and","gradients","are","obtained","through","an","external","C","implementation",",","that","uses","the","library","directly","."]
code: def run_ctc(
      self,
      activations,
      labels,
      input_length,
      expected_costs,
      expected_grads,
  ):
      # Create symbolic variables
      t_activations = theano.shared(activations, name="activations")
      t_activation_times = theano.shared(
          input_length, name="activation_times"
      )
      t_labels = theano.shared(labels, name="labels")
  
      t_cost = ctc(t_activations, t_labels, t_activation_times)
      # Symbolic gradient of CTC cost
      t_grad = T.grad(T.mean(t_cost), t_activations)
      # Compile symbolic functions
      train = theano.function([], [t_cost, t_grad])
  
      cost, grad = train()
  
      utt.assert_allclose(expected_grads / cost.shape[0], grad)
      utt.assert_allclose(expected_costs, cost)
  
      self.check_grads_disabled(
          t_activations, t_labels, t_activation_times
      )
  
file_path: Theano/theano/tensor/nnet/tests/test_ctc.py
imports: from __future__ import division, absolute_import, print_function
  import unittest
  from nose.plugins.skip import SkipTest
  import numpy
  import theano
  import theano.tensor
  from theano.tests import unittest_tools
  from theano.tensor.nnet.ctc import ctc_available, ctc, ConnectionistTemporalClassification
label_desc: Use image node_id 2 for calling the TestCTC obj's underlying member method code with example usage: obj.run_ctc(activations, labels, input_length, expected_costs, expected_grads) without return types