parameters: (batch)
return_statement: return image_annotation, images, meta_data
docstring: Processes batch data and returns lists of annotations, images and batch meta data
          :param batch: a list with batch data.
                        Possible formats: [((img_id, label), image)]
                                          [({img_id: label}, image)]
          :returns a list with annotations [(img_id, label)]
                   a list with input data  [image]
                   a list with batch meta data
docstring_summary: Processes batch data and returns lists of annotations, images and batch meta data
          :param batch: a list with batch data.
                        Possible formats: [((img_id, label), image)]
                                          [({img_id: label}, image)]
          :returns a list with annotations [(img_id, label)]
                   a list with input data  [image]
                   a list with batch meta data
docstring_tokens: Processes batch data and returns lists of annotations images and batch meta data : param batch : a list with batch data . Possible formats : [ (( img_id label ) image ) ] [ ( { img_id : label } image ) ] : returns a list with annotations [ ( img_id label ) ] a list with input data [ image ] a list with batch meta data
function: def _process_batch(batch):
          """ Processes batch data and returns lists of annotations, images and batch meta data
          :param batch: a list with batch data.
                        Possible formats: [((img_id, label), image)]
                                          [({img_id: label}, image)]
          :returns a list with annotations [(img_id, label)]
                   a list with input data  [image]
                   a list with batch meta data
          """
          if not all([isinstance(item, tuple) for item in batch]):
              raise RuntimeError('Inconsistent data in the batch. '
                                 'Some items contain annotation, and some do not.')
  
          if all([len(item) == 2 for item in batch]):
              image_annotation, images = map(list, zip(*batch))
              meta_data = [{}]*len(images)
          elif all([len(item) == 3 for item in batch]):
              image_annotation, images, meta_data = map(list, zip(*batch))
          else:
              raise RuntimeError('Inconsistent data in the batch. '
                                 'Some items contain meta data, and some do not.')
  
          # if image annotations are represented as dictionaries, convert them to tuples
          if image_annotation is not None and all([isinstance(item, dict) for item in image_annotation]):
              image_annotation = [(img_id, label) for sample_annot in image_annotation
                                  for img_id, label in sample_annot.items()]
  
          return image_annotation, images, meta_data
function_tokens: def _process_batch ( batch ) : if not all ( [ isinstance ( item , tuple ) for item in batch ] ) : raise RuntimeError ( 'Inconsistent data in the batch. ' 'Some items contain annotation, and some do not.' ) if all ( [ len ( item ) == 2 for item in batch ] ) : image_annotation , images = map ( list , zip ( * batch ) ) meta_data = [ { } ] * len ( images ) elif all ( [ len ( item ) == 3 for item in batch ] ) : image_annotation , images , meta_data = map ( list , zip ( * batch ) ) else : raise RuntimeError ( 'Inconsistent data in the batch. ' 'Some items contain meta data, and some do not.' ) # if image annotations are represented as dictionaries, convert them to tuples if image_annotation is not None and all ( [ isinstance ( item , dict ) for item in image_annotation ] ) : image_annotation = [ ( img_id , label ) for sample_annot in image_annotation for img_id , label in sample_annot . items ( ) ] return image_annotation , images , meta_data