original_docstring: 
      Collate function to be used when wrapping a CLEVRDialogDataset in a
      DataLoader. Returns a tuple of the following:
  
      - imgs: FloatTensor of shape (N, C, H, W)
      - objs: LongTensor of shape (O,) giving categories for all objects
      - boxes: FloatTensor of shape (O, 4) giving boxes for all objects
      - triplets: FloatTensor of shape (T, 3) giving all triplets, where
      triplets[t] = [i, p, j] means that [objs[i], p, objs[j]] is a triple
      - obj_to_img: LongTensor of shape (O,) mapping objects to images;
      obj_to_img[i] = n means that objs[i] belongs to imgs[n]
      - triple_to_img: LongTensor of shape (T,) mapping triplets to images;
      triple_to_img[t] = n means that triplets[t] belongs to imgs[n].
      
docstring: Collate function to be used when wrapping a CLEVRDialogDataset in a
  DataLoader. Returns a tuple of the following.
  
  
docstring_tokens: Collate function to be used when wrapping a CLEVRDialogDataset in a DataLoader . Returns a tuple of the following .
code: def clevr_collate_fn_fix(vocab, batch):
      """
      Collate function to be used when wrapping a CLEVRDialogDataset in a
      DataLoader. Returns a tuple of the following:
  
      - imgs: FloatTensor of shape (N, C, H, W)
      - objs: LongTensor of shape (O,) giving categories for all objects
      - boxes: FloatTensor of shape (O, 4) giving boxes for all objects
      - triplets: FloatTensor of shape (T, 3) giving all triplets, where
      triplets[t] = [i, p, j] means that [objs[i], p, objs[j]] is a triple
      - obj_to_img: LongTensor of shape (O,) mapping objects to images;
      obj_to_img[i] = n means that objs[i] belongs to imgs[n]
      - triple_to_img: LongTensor of shape (T,) mapping triplets to images;
      triple_to_img[t] = n means that triplets[t] belongs to imgs[n].
      """
      # batch is a list, and each element is (image, objs, boxes, triplets)
      all_imgs, all_boxes, all_triplets, all_original_triplets = [], [], [], []
      all_objs = []
      all_masks = []
      all_image_ids = []
      all_obj_to_img, all_triple_to_img = [], []
  
      max_triplets = 0
      max_objects = 0
      for i, (img, objs, boxes, triplets, _) in enumerate(batch):
          O = objs[list(objs.keys())[0]].size(0)
          T = triplets.size(0)
  
          if max_objects < O:
              max_objects = O
  
          if max_triplets < T:
              max_triplets = T
  
      for i, (img, objs, boxes, triplets, sg) in enumerate(batch):
          all_imgs.append(img[None])
          all_image_ids.append(int(re.findall(r'\d+', sg['image_filename'])[0]))
          O, T = objs[list(objs.keys())[0]].size(0), triplets.size(0)
  
          # Padded objs
          attributes = list(objs.keys())
          sorted(attributes)
          attributes_to_index = {attributes[i]: i for i in range(len(attributes))}
          attributes_objects = torch.zeros(len(attributes), max_objects, dtype=torch.long)
  
          for k, v in objs.items():
              # Padded objects
              if max_objects - O > 0:
                  zeros_v = torch.zeros(max_objects - O, dtype=torch.long)
                  padd_v = torch.cat([v, zeros_v])
              else:
                  padd_v = v
              attributes_objects[attributes_to_index[k], :] = padd_v
          attributes_objects = attributes_objects.transpose(1, 0)
  
          # Padded boxes
          if max_objects - O > 0:
              padded_boxes = torch.FloatTensor([[-1, -1, -1, -1]]).repeat(max_objects - O, 1)
              boxes = torch.cat([boxes, padded_boxes])
  
          # Padded triplets
          if max_triplets - T > 0:
              padded_triplets = torch.LongTensor([[0, vocab["pred_name_to_idx"]["__padding__"], 0]]).repeat(
                  max_triplets - T, 1)
              triplets = torch.cat([triplets, padded_triplets])
  
          all_objs.append(attributes_objects)
          all_triplets.append(triplets)
          all_boxes.append(boxes)
  
      all_imgs = torch.cat(all_imgs)
      all_objs = torch.stack(all_objs, dim=0)
      all_boxes = torch.stack(all_boxes, dim=0)
      all_triplets = torch.stack(all_triplets, dim=0)
      all_image_ids = torch.LongTensor(all_image_ids)
      out = (all_imgs, all_objs, all_boxes, all_triplets, all_image_ids, None)
      return out
code_tokens: def clevr_collate_fn_fix ( vocab , batch ) : all_imgs , all_boxes , all_triplets , all_original_triplets = [ ] , [ ] , [ ] , [ ] all_objs = [ ] all_masks = [ ] all_image_ids = [ ] all_obj_to_img , all_triple_to_img = [ ] , [ ] max_triplets = 0 max_objects = 0 for i , ( img , objs , boxes , triplets , _ ) in enumerate ( batch ) : O = objs [ list ( objs . keys ( ) ) [ 0 ] ] . size ( 0 ) T = triplets . size ( 0 ) if max_objects < O : max_objects = O if max_triplets < T : max_triplets = T for i , ( img , objs , boxes , triplets , sg ) in enumerate ( batch ) : all_imgs . append ( img [ None ] ) all_image_ids . append ( int ( re . findall ( r'\d+' , sg [ 'image_filename' ] ) [ 0 ] ) ) O , T = objs [ list ( objs . keys ( ) ) [ 0 ] ] . size ( 0 ) , triplets . size ( 0 ) attributes = list ( objs . keys ( ) ) sorted ( attributes ) attributes_to_index = { attributes [ i ] : i for i in range ( len ( attributes ) ) } attributes_objects = torch . zeros ( len ( attributes ) , max_objects , dtype = torch . long ) for k , v in objs . items ( ) : if max_objects - O > 0 : zeros_v = torch . zeros ( max_objects - O , dtype = torch . long ) padd_v = torch . cat ( [ v , zeros_v ] ) else : padd_v = v attributes_objects [ attributes_to_index [ k ] , : ] = padd_v attributes_objects = attributes_objects . transpose ( 1 , 0 ) if max_objects - O > 0 : padded_boxes = torch . FloatTensor ( [ [ - 1 , - 1 , - 1 , - 1 ] ] ) . repeat ( max_objects - O , 1 ) boxes = torch . cat ( [ boxes , padded_boxes ] ) if max_triplets - T > 0 : padded_triplets = torch . LongTensor ( [ [ 0 , vocab [ "pred_name_to_idx" ] [ "__padding__" ] , 0 ] ] ) . repeat ( max_triplets - T , 1 ) triplets = torch . cat ( [ triplets , padded_triplets ] ) all_objs . append ( attributes_objects ) all_triplets . append ( triplets ) all_boxes . append ( boxes ) all_imgs = torch . cat ( all_imgs ) all_objs = torch . stack ( all_objs , dim = 0 ) all_boxes = torch . stack ( all_boxes , dim = 0 ) all_triplets = torch . stack ( all_triplets , dim = 0 ) all_image_ids = torch . LongTensor ( all_image_ids ) out = ( all_imgs , all_objs , all_boxes , all_triplets , all_image_ids , None ) return out
short_docstring: Collate function to be used when wrapping a CLEVRDialogDataset in a
  DataLoader.
short_docstring_tokens: Collate function to be used when wrapping a CLEVRDialogDataset in a DataLoader .
comment: """
      Collate function to be used when wrapping a CLEVRDialogDataset in a
      DataLoader. Returns a tuple of the following:
  
      - imgs: FloatTensor of shape (N, C, H, W)
      - objs: LongTensor of shape (O,) giving categories for all objects
      - boxes: FloatTensor of shape (O, 4) giving boxes for all objects
      - triplets: FloatTensor of shape (T, 3) giving all triplets, where
      triplets[t] = [i, p, j] means that [objs[i], p, objs[j]] is a triple
      - obj_to_img: LongTensor of shape (O,) mapping objects to images;
      obj_to_img[i] = n means that objs[i] belongs to imgs[n]
      - triple_to_img: LongTensor of shape (T,) mapping triplets to images;
      triple_to_img[t] = n means that triplets[t] belongs to imgs[n].
      """$SEP$# batch is a list, and each element is (image, objs, boxes, triplets)$SEP$# Padded objs$SEP$# Padded objects$SEP$# Padded boxes$SEP$# Padded triplets