parameters: (f)
return_statement: return train_images, train_labels, test_images, test_labels
docstring: Extract the images into a 4D uint8 numpy array [index, y, x, depth].
      Args:
        f: A file object that can be passed into a gzip reader.
      Returns:
        data: A 4D uint8 numpy array [index, y, x, depth].
      Raises:
        ValueError: If the bytestream does not start with 2051.
docstring_summary: Extract the images into a 4D uint8 numpy array [index, y, x, depth].
      Args:
        f: A file object that can be passed into a gzip reader.
      Returns:
        data: A 4D uint8 numpy array [index, y, x, depth].
      Raises:
        ValueError: If the bytestream does not start with 2051.
docstring_tokens: Extract the images into a 4D uint8 numpy array [ index y x depth ] . Args : f : A file object that can be passed into a gzip reader . Returns : data : A 4D uint8 numpy array [ index y x depth ] . Raises : ValueError : If the bytestream does not start with 2051 .
function: def extract_images(f):
      """Extract the images into a 4D uint8 numpy array [index, y, x, depth].
      Args:
        f: A file object that can be passed into a gzip reader.
      Returns:
        data: A 4D uint8 numpy array [index, y, x, depth].
      Raises:
        ValueError: If the bytestream does not start with 2051.
      """
      train_images = []
      train_labels = []
      test_images = []
      test_labels = []
      print('Extracting', f.name)
      with tarfile.TarFile(fileobj=gzip.GzipFile(fileobj=f)) as tfile:
          for name in tfile.getnames():
              if 'data_batch' in name:
                  fd = tfile.extractfile(name)
                  data = cPickle.load(fd)
                  for image, label in zip(data['data'], data['labels']):
                      image = np.array(image)
                      train_images.append(image)
                      train_labels.append(label)
              elif 'test_batch' in name:
                  fd = tfile.extractfile(name)
                  data = cPickle.load(fd)
                  for image, label in zip(data['data'], data['labels']):
                      image = np.array(image)
                      test_images.append(image)
                      test_labels.append(label)
              else:
                  continue
  
      return train_images, train_labels, test_images, test_labels
function_tokens: def extract_images ( f ) : train_images = [ ] train_labels = [ ] test_images = [ ] test_labels = [ ] print ( 'Extracting' , f . name ) with tarfile . TarFile ( fileobj = gzip . GzipFile ( fileobj = f ) ) as tfile : for name in tfile . getnames ( ) : if 'data_batch' in name : fd = tfile . extractfile ( name ) data = cPickle . load ( fd ) for image , label in zip ( data [ 'data' ] , data [ 'labels' ] ) : image = np . array ( image ) train_images . append ( image ) train_labels . append ( label ) elif 'test_batch' in name : fd = tfile . extractfile ( name ) data = cPickle . load ( fd ) for image , label in zip ( data [ 'data' ] , data [ 'labels' ] ) : image = np . array ( image ) test_images . append ( image ) test_labels . append ( label ) else : continue return train_images , train_labels , test_images , test_labels