parameters: (source_desc: SourceDescription)
return_statement: return CallableBatchIterator, dtype, shape
docstring: Transform batch callback accepting one argument into an Iterable
docstring_summary: Transform batch callback accepting one argument into an Iterable
docstring_tokens: Transform batch callback accepting one argument into an Iterable
function: def get_batch_iterable_from_callback(source_desc: SourceDescription):
      """Transform batch callback accepting one argument into an Iterable
      """
      first = source_desc.source(types.BatchInfo(0, 0) if source_desc.batch_info else 0)
      dtype, shape = _inspect_data(first, True)
  
      class CallableBatchIterator:
          first_value = first
  
          def __init__(self):
              self.iteration = 0
              self.source = source_desc.source
  
          def __iter__(self):
              self.iteration = 0
              return self
  
          def __next__(self):
              if self.iteration == 0 and CallableBatchIterator.first_value is not None:
                  result = CallableBatchIterator.first_value
                  CallableBatchIterator.first_value = None
              else:
                  if source_desc.batch_info:
                      # There is no notion of epochs when iterating over DALI Dataset
                      # as the "raise" policy is not supported, so we use epoch 0 only.
                      argument = types.BatchInfo(self.iteration, 0)
                  else:
                      argument = self.iteration
                  result = self.source(argument)
              self.iteration += 1
              return batch_to_numpy(result, _tf_batch_error_msg, non_uniform_str=_tf_uniform_error_msg)
  
      return CallableBatchIterator, dtype, shape
function_tokens: def get_batch_iterable_from_callback ( source_desc : SourceDescription ) : first = source_desc . source ( types . BatchInfo ( 0 , 0 ) if source_desc . batch_info else 0 ) dtype , shape = _inspect_data ( first , True ) class CallableBatchIterator : first_value = first def __init__ ( self ) : self . iteration = 0 self . source = source_desc . source def __iter__ ( self ) : self . iteration = 0 return self def __next__ ( self ) : if self . iteration == 0 and CallableBatchIterator . first_value is not None : result = CallableBatchIterator . first_value CallableBatchIterator . first_value = None else : if source_desc . batch_info : # There is no notion of epochs when iterating over DALI Dataset # as the "raise" policy is not supported, so we use epoch 0 only. argument = types . BatchInfo ( self . iteration , 0 ) else : argument = self . iteration result = self . source ( argument ) self . iteration += 1 return batch_to_numpy ( result , _tf_batch_error_msg , non_uniform_str = _tf_uniform_error_msg ) return CallableBatchIterator , dtype , shape