title: How to write collate_fn correctly in my case?
body: <p>Please, could you help me to find the solution to my problem. I want to write collate_fn to make my pictures the equal size, but I don't know how to implement it correctly.</p>
  <p>Colab: <a href="https://colab.research.google.com/drive/1vi0gc5_k-3Alxp-_9Jyp5Jyvoe_lo9O9#scrollTo=l4S0dRJDikTS" rel="nofollow noreferrer">link</a></p>
  <p>Code:</p>
  <pre><code>import pandas as pd
  import numpy as np
  from PIL import Image
  
  from torchvision import transforms
  from torch.utils.data.dataset import Dataset  # For custom datasets
  
  
  class CustomDataset(Dataset):
      def __init__(self, csv_path):
          self.to_tensor = transforms.ToTensor()
          self.data_info = csv_path
          # First column contains the image paths
          self.image_arr = np.asarray(self.data_info.iloc[:, 0])
          # Second column is the labels
          self.label_arr = np.asarray(self.data_info.iloc[:, 1])
          # Calculate len
          self.data_len = len(self.data_info.index)
  
      def __getitem__(self, index):
          # Get image name from the pandas df
          single_image_name = self.image_arr[index]
          # Open image        
          IMAGE_SIZE = [224,224]
  
          response = requests.get(single_image_name)
          img_as_img = Image.open(BytesIO(response.content)).resize(IMAGE_SIZE)
  
          # Transform image to tensor
          img_as_tensor = self.to_tensor(img_as_img)
  
          # Get label(class) of the image based on the cropped pandas column
          single_image_label = self.label_arr[index]
  
          return (img_as_tensor, single_image_label)
  
      def __len__(self):
          return self.data_len
  </code></pre>