class_docstr: Internal representation of minibatch data.
  
  Args:
      batch: batch input for `var`.
       It can be:
  
        * a pure Python structure (list of lists, ...),
        * a list of NumPy arrays or SciPy sparse CSR matrices
        * a :class:`~cntk.core.Value` object (e.g. returned by :func:`one_hot`)
      seq_starts (list of `bool`\ s or None): if None, every sequence is
       treated as a new sequence. Otherwise, it is interpreted as a list of
       Booleans that tell whether a sequence is a new sequence (`True`) or a
       continuation of the sequence in the same slot of the previous
       minibatch (`False`)
      device (:class:`~cntk.device.DeviceDescriptor`): device this value
       should be put on
class_docstr_tok: ["Internal","representation","of","minibatch","data",".","Args",":","batch",":","batch","input","for","`","var","`",".","It","can","be",":","*","a","pure","Python","structure","(","list","of","lists",",","...",")",",","*","a","list","of","NumPy","arrays","or","SciPy","sparse","CSR","matrices","*","a",":","class",":","`","~cntk.core.Value","`","object","(","e.g",".","returned","by",":","func",":","`","one_hot","`",")","seq_starts","(","list","of","`","bool","`","\\","s","or","None",")",":","if","None",",","every","sequence","is","treated","as","a","new","sequence",".","Otherwise",",","it","is","interpreted","as","a","list","of","Booleans","that","tell","whether","a","sequence","is","a","new","sequence","(","`","True","`",")","or","a","continuation","of","the","sequence","in","the","same","slot","of","the","previous","minibatch","(","`","False","`",")","device","(",":","class",":","`","~cntk.device.DeviceDescriptor","`",")",":","device","this","value","should","be","put","on"]
docstr: Converts ``batch`` into a :class:`~cntk.core.Value` object of ``dtype``
  such that the integer data in ``batch`` is interpreted as the indices
  representing one-hot vectors. Use Value.ONE_HOT_SKIP for a zero vector
  
  Example:
      >>> num_classes = 6
      >>> sparse_indices = [[1,C.Value.ONE_HOT_SKIP,5],[4]]
      >>> i0 = C.sequence.input_variable(shape=num_classes, is_sparse=True)
      >>> z = C.times(i0, np.eye(num_classes))
      >>> value = C.Value.one_hot(sparse_indices, num_classes)
      >>> z.eval({i0: value})
      [array([[0., 1., 0., 0., 0., 0.],
             [0., 0., 0., 0., 0., 0.],
             [0., 0., 0., 0., 0., 1.]], dtype=float32), array([[0., 0., 0., 0., 1., 0.]], dtype=float32)]
      >>> num_classes = 6
      >>> sample_shape = (2, num_classes)
      >>> sparse_indices = [[1,5,3,2],[4,1]]
      >>> i0 = C.sequence.input_variable(shape=sample_shape, is_sparse=True)
      >>> z = C.times(i0, np.eye(num_classes))
      >>> value = C.Value.one_hot(sparse_indices, sample_shape)
      >>> z.eval({i0: value})
      [array([[[ 0.,  1.,  0.,  0.,  0.,  0.],
               [ 0.,  0.,  0.,  0.,  0.,  1.]],
              [[ 0.,  0.,  0.,  1.,  0.,  0.],
               [ 0.,  0.,  1.,  0.,  0.,  0.]]], dtype=float32),
       array([[[ 0.,  0.,  0.,  0.,  1.,  0.],
               [ 0.,  1.,  0.,  0.,  0.,  0.]]], dtype=float32)]
      >>> # this example has no sequence axis:
      >>> num_classes = 6
      >>> sample_shape = (num_classes,)
      >>> sparse_indices = [1,5,3,2]
      >>> i0 = C.input_variable(shape=sample_shape, is_sparse=True)
      >>> z = C.times(i0, np.eye(num_classes))
      >>> value = C.Value.one_hot(sparse_indices, sample_shape)
      >>> z.eval({i0: value})
      array([[ 0.,  1.,  0.,  0.,  0.,  0.],
             [ 0.,  0.,  0.,  0.,  0.,  1.],
             [ 0.,  0.,  0.,  1.,  0.,  0.],
             [ 0.,  0.,  1.,  0.,  0.,  0.]], dtype=float32)
  
  Args:
      batch (list of lists of integers): batch input data of indices
      sample_shape (int or tuple): number of classes or shape of each
       sample whose trailing axis is one_hot
      dtype (`np.float32`, `np.float64`, `np.float16`, default None): data type
      device (:class:`~cntk.device.DeviceDescriptor`, default None): device
       this value should be put on
  
  Returns:
      ``batch`` converted into a :class:`~Value` object that can be passed to
      the forward or eval function.
docstr_tok: ["Converts","``","batch","``","into","a",":","class",":","`","~cntk.core.Value","`","object","of","``","dtype","``","such","that","the","integer","data","in","``","batch","``","is","interpreted","as","the","indices","representing","one-hot","vectors",".","Use","Value.ONE_HOT_SKIP","for","a","zero","vector","Example",":",">",">",">","num_classes","=","6",">",">",">","sparse_indices","=","[","[","1",",","C.Value.ONE_HOT_SKIP,5","]",",","[","4","]","]",">",">",">","i0","=","C.sequence.input_variable","(","shape=num_classes",",","is_sparse=True",")",">",">",">","z","=","C.times","(","i0",",","np.eye","(","num_classes",")",")",">",">",">","value","=","C.Value.one_hot","(","sparse_indices",",","num_classes",")",">",">",">","z.eval","(","{","i0",":","value","}",")","[","array","(","[","[","0.",",","1.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","1",".","]","]",",","dtype=float32",")",",","array","(","[","[","0.",",","0.",",","0.",",","0.",",","1.",",","0",".","]","]",",","dtype=float32",")","]",">",">",">","num_classes","=","6",">",">",">","sample_shape","=","(","2",",","num_classes",")",">",">",">","sparse_indices","=","[","[","1,5,3,2","]",",","[","4,1","]","]",">",">",">","i0","=","C.sequence.input_variable","(","shape=sample_shape",",","is_sparse=True",")",">",">",">","z","=","C.times","(","i0",",","np.eye","(","num_classes",")",")",">",">",">","value","=","C.Value.one_hot","(","sparse_indices",",","sample_shape",")",">",">",">","z.eval","(","{","i0",":","value","}",")","[","array","(","[","[","[","0.",",","1.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","1",".","]","]",",","[","[","0.",",","0.",",","0.",",","1.",",","0.",",","0",".","]",",","[","0.",",","0.",",","1.",",","0.",",","0.",",","0",".","]","]","]",",","dtype=float32",")",",","array","(","[","[","[","0.",",","0.",",","0.",",","0.",",","1.",",","0",".","]",",","[","0.",",","1.",",","0.",",","0.",",","0.",",","0",".","]","]","]",",","dtype=float32",")","]",">",">",">","#","this","example","has","no","sequence","axis",":",">",">",">","num_classes","=","6",">",">",">","sample_shape","=","(","num_classes",",",")",">",">",">","sparse_indices","=","[","1,5,3,2","]",">",">",">","i0","=","C.input_variable","(","shape=sample_shape",",","is_sparse=True",")",">",">",">","z","=","C.times","(","i0",",","np.eye","(","num_classes",")",")",">",">",">","value","=","C.Value.one_hot","(","sparse_indices",",","sample_shape",")",">",">",">","z.eval","(","{","i0",":","value","}",")","array","(","[","[","0.",",","1.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","1",".","]",",","[","0.",",","0.",",","0.",",","1.",",","0.",",","0",".","]",",","[","0.",",","0.",",","1.",",","0.",",","0.",",","0",".","]","]",",","dtype=float32",")","Args",":","batch","(","list","of","lists","of","integers",")",":","batch","input","data","of","indices","sample_shape","(","int","or","tuple",")",":","number","of","classes","or","shape","of","each","sample","whose","trailing","axis","is","one_hot","dtype","(","`","np.float32","`",",","`","np.float64","`",",","`","np.float16","`",",","default","None",")",":","data","type","device","(",":","class",":","`","~cntk.device.DeviceDescriptor","`",",","default","None",")",":","device","this","value","should","be","put","on","Returns",":","``","batch","``","converted","into","a",":","class",":","`","~Value","`","object","that","can","be","passed","to","the","forward","or","eval","function","."]
code: def one_hot(batch, num_classes, dtype=None, device=None):
      """
      Converts ``batch`` into a :class:`~cntk.core.Value` object of ``dtype``
      such that the integer data in ``batch`` is interpreted as the indices
      representing one-hot vectors. Use Value.ONE_HOT_SKIP for a zero vector
  
      Example:
          >>> num_classes = 6
          >>> sparse_indices = [[1,C.Value.ONE_HOT_SKIP,5],[4]]
          >>> i0 = C.sequence.input_variable(shape=num_classes, is_sparse=True)
          >>> z = C.times(i0, np.eye(num_classes))
          >>> value = C.Value.one_hot(sparse_indices, num_classes)
          >>> z.eval({i0: value})
          [array([[0., 1., 0., 0., 0., 0.],
                 [0., 0., 0., 0., 0., 0.],
                 [0., 0., 0., 0., 0., 1.]], dtype=float32), array([[0., 0., 0., 0., 1., 0.]], dtype=float32)]
          >>> num_classes = 6
          >>> sample_shape = (2, num_classes)
          >>> sparse_indices = [[1,5,3,2],[4,1]]
          >>> i0 = C.sequence.input_variable(shape=sample_shape, is_sparse=True)
          >>> z = C.times(i0, np.eye(num_classes))
          >>> value = C.Value.one_hot(sparse_indices, sample_shape)
          >>> z.eval({i0: value})
          [array([[[ 0.,  1.,  0.,  0.,  0.,  0.],
                   [ 0.,  0.,  0.,  0.,  0.,  1.]],
                  [[ 0.,  0.,  0.,  1.,  0.,  0.],
                   [ 0.,  0.,  1.,  0.,  0.,  0.]]], dtype=float32),
           array([[[ 0.,  0.,  0.,  0.,  1.,  0.],
                   [ 0.,  1.,  0.,  0.,  0.,  0.]]], dtype=float32)]
          >>> # this example has no sequence axis:
          >>> num_classes = 6
          >>> sample_shape = (num_classes,)
          >>> sparse_indices = [1,5,3,2]
          >>> i0 = C.input_variable(shape=sample_shape, is_sparse=True)
          >>> z = C.times(i0, np.eye(num_classes))
          >>> value = C.Value.one_hot(sparse_indices, sample_shape)
          >>> z.eval({i0: value})
          array([[ 0.,  1.,  0.,  0.,  0.,  0.],
                 [ 0.,  0.,  0.,  0.,  0.,  1.],
                 [ 0.,  0.,  0.,  1.,  0.,  0.],
                 [ 0.,  0.,  1.,  0.,  0.,  0.]], dtype=float32)
  
      Args:
          batch (list of lists of integers): batch input data of indices
          sample_shape (int or tuple): number of classes or shape of each
           sample whose trailing axis is one_hot
          dtype (`np.float32`, `np.float64`, `np.float16`, default None): data type
          device (:class:`~cntk.device.DeviceDescriptor`, default None): device
           this value should be put on
  
      Returns:
          ``batch`` converted into a :class:`~Value` object that can be passed to
          the forward or eval function.
      """
      if device is None:
          device = use_default_device()
  
      if isinstance(num_classes, numbers.Integral):
          sample_shape = (num_classes,)
      else:
          sample_shape = num_classes
  
      if isinstance(batch, np.ndarray):
          batch = batch.tolist()
      elif not isinstance(batch, list):  # TODO: allow general iterables
          raise ValueError("input must be a list")
      remove_sequence_axis = False
      if isinstance(batch, list) and isinstance(batch[0], np.ndarray):
          batch = [b.tolist() for b in batch]
      elif isinstance(batch, list) and isinstance(
          batch[0], (int, float)
      ):
          remove_sequence_axis = True  # has no sequence axis
          batch = [[b] for b in batch]
  
      try:
          elem = batch[0][0]
      except:
          raise ValueError("input must be a list of list of integers")
  
      if not isinstance(elem, numbers.Integral):
          data_type = type(elem)
          raise ValueError(
              "supplied data to one_hot() must be of type integer"
              ' and not "%s" since it is index data.' % data_type
          )
  
      if dtype in [np.float32, None]:
          value = cntk_py.Value.create_one_hot_float(
              sample_shape, batch, device, False
          )
      elif dtype == np.float64:
          value = cntk_py.Value.create_one_hot_double(
              sample_shape, batch, device, False
          )
      elif dtype == np.float16:
          value = cntk_py.Value.create_one_hot_float16(
              sample_shape, batch, device, False
          )
      if (
          remove_sequence_axis
      ):  # added an axis that we should strip again now
          shape = (len(batch),) + sample_shape
          data = value.data().as_shape(shape)
          value = Value(data)
      return value
  
imports: import warnings
  import numbers
  import numpy
  from scipy import sparse
  from .None import cntk_py
  from .device import use_default_device, cpu, DeviceKind
  from cntk.internal import typemap
  from cntk.internal.sanitize import sanitize_batch, _sparse_to_dense_network_cache, data_type_to_dtype
label_desc: Use image node_id 5 for calling the Value obj's underlying member method code with example usage: obj.one_hot(batch, num_classes, dtype, device) and returns: value