class_docstr: Get data directly from caltech101 dataset from Internet.
class_docstr_tok: ["Get","data","directly","from","caltech101","dataset","from","Internet","."]
code: def _resize_image(self, im, width, height, padding):
      # resize
      h = im.shape[0]
      w = im.shape[1]
      if w != width or h != height:
          # resize image
          if not padding:
              # trimming mode
              if float(h) / w > float(height) / width:
                  target_h = int(float(w) / width * height)
                  im = im[
                      (h - target_h) // 2 : h - (h - target_h) // 2, ::
                  ]
              else:
                  target_w = int(float(h) / height * width)
                  im = im[
                      ::, (w - target_w) // 2 : w - (w - target_w) // 2
                  ]
          else:
              # padding mode
              if float(h) / w < float(height) / width:
                  target_h = int(float(height) / width * w)
                  pad = (
                      (
                          (target_h - h) // 2,
                          target_h - (target_h - h) // 2 - h,
                      ),
                      (0, 0),
                  )
              else:
                  target_w = int(float(width) / height * h)
                  pad = (
                      (0, 0),
                      (
                          (target_w - w) // 2,
                          target_w - (target_w - w) // 2 - w,
                      ),
                  )
              pad = pad + ((0, 0),)
              im = np.pad(im, pad, "constant")
          im = imresize(im, (width, height))
      x = np.array(im, dtype=np.uint8).transpose((2, 0, 1))
      return x
  
file_path: nnabla/tutorial/caltech101_data.py
imports: import numpy
  import tarfile
  import zipfile
  from io import BytesIO
  from nnabla.logger import logger
  from nnabla.utils.data_iterator import data_iterator
  from nnabla.utils.data_source import DataSource
  from nnabla.utils.data_source_loader import download, get_data_home
  from nnabla.utils.image_utils import imresize, imread
label_desc: Use image node_id 1 for calling the Caltech101DataSource obj's underlying member method code with example usage: obj._resize_image(im, width, height, padding) and returns: x