original_docstring: 
      Scales, crops, and normalizes a PIL image for a PyTorch model,
      returns an Numpy array
      
docstring: Scales, crops, and normalizes a PIL image for a PyTorch model,
  returns an Numpy array
docstring_tokens: Scales crops and normalizes a PIL image for a PyTorch model returns an Numpy array
code: def process_image(image_path):
      '''
      Scales, crops, and normalizes a PIL image for a PyTorch model,
      returns an Numpy array
      '''
      # Process a PIL image for use in a PyTorch model
  
      pil_image = Image.open(image_path)
  
      # Resize
      if pil_image.size[0] > pil_image.size[1]:
          pil_image.thumbnail((5000, 256))
      else:
          pil_image.thumbnail((256, 5000))
  
      # Crop
      left_margin = (pil_image.width-256)/2
      bottom_margin = (pil_image.height-256)/2
      right_margin = left_margin + 256
      top_margin = bottom_margin + 256
  
      pil_image = pil_image.crop(
          (left_margin, bottom_margin, right_margin, top_margin))
  
      # Normalize
      np_image = np.array(pil_image)/255
      mean = np.array([0.485, 0.456, 0.406])
      std = np.array([0.229, 0.224, 0.225])
      np_image = (np_image - mean) / std
  
      # PyTorch expects the color channel to be the
      # first dimension but it's the third dimension
      # in the PIL image and Numpy array
      # Color channel needs to be first;
      # retain the order of the other two dimensions.
      np_image = np_image.transpose((2, 0, 1))
  
      return np_image
code_tokens: def process_image ( image_path ) : pil_image = Image . open ( image_path ) if pil_image . size [ 0 ] > pil_image . size [ 1 ] : pil_image . thumbnail ( ( 5000 , 256 ) ) else : pil_image . thumbnail ( ( 256 , 5000 ) ) left_margin = ( pil_image . width - 256 ) / 2 bottom_margin = ( pil_image . height - 256 ) / 2 right_margin = left_margin + 256 top_margin = bottom_margin + 256 pil_image = pil_image . crop ( ( left_margin , bottom_margin , right_margin , top_margin ) ) np_image = np . array ( pil_image ) / 255 mean = np . array ( [ 0.485 , 0.456 , 0.406 ] ) std = np . array ( [ 0.229 , 0.224 , 0.225 ] ) np_image = ( np_image - mean ) / std np_image = np_image . transpose ( ( 2 , 0 , 1 ) ) return np_image
short_docstring: Scales, crops, and normalizes a PIL image for a PyTorch model,
  returns an Numpy array
short_docstring_tokens: Scales crops and normalizes a PIL image for a PyTorch model returns an Numpy array
comment: '''
      Scales, crops, and normalizes a PIL image for a PyTorch model,
      returns an Numpy array
      '''$SEP$# Process a PIL image for use in a PyTorch model$SEP$# Resize$SEP$# Crop$SEP$# Normalize$SEP$# PyTorch expects the color channel to be the$SEP$# first dimension but it's the third dimension$SEP$# in the PIL image and Numpy array$SEP$# Color channel needs to be first;$SEP$# retain the order of the other two dimensions.