class_docstr: Abstract decoder for :class:`~ffcv.fields.RGBImageField` that performs a crop and and a resize operation.
  
  It supports both variable and constant resolution datasets.
class_docstr_tok: ["Abstract","decoder","for",":","class",":","`","~ffcv.fields.RGBImageField","`","that","performs","a","crop","and","and","a","resize","operation",".","It","supports","both","variable","and","constant","resolution","datasets","."]
code: def generate_code(self) -> Callable:
      jpg = IMAGE_MODES["jpg"]
  
      mem_read = self.memory_read
      my_range = Compiler.get_iterator()
      imdecode_c = Compiler.compile(imdecode)
      resize_crop_c = Compiler.compile(resize_crop)
      get_crop_c = Compiler.compile(self.get_crop_generator)
  
      scale = self.scale
      ratio = self.ratio
      if isinstance(scale, tuple):
          scale = np.array(scale)
      if isinstance(ratio, tuple):
          ratio = np.array(ratio)
  
      def decode(batch_indices, my_storage, metadata, storage_state):
          destination, temp_storage = my_storage
          for dst_ix in my_range(len(batch_indices)):
              source_ix = batch_indices[dst_ix]
              field = metadata[source_ix]
              image_data = mem_read(field["data_ptr"], storage_state)
              height = np.uint32(field["height"])
              width = np.uint32(field["width"])
  
              if field["mode"] == jpg:
                  temp_buffer = temp_storage[dst_ix]
                  imdecode_c(
                      image_data,
                      temp_buffer,
                      height,
                      width,
                      height,
                      width,
                      0,
                      0,
                      1,
                      1,
                      False,
                      False,
                  )
                  selected_size = 3 * height * width
                  temp_buffer = temp_buffer.reshape(-1)[:selected_size]
                  temp_buffer = temp_buffer.reshape(height, width, 3)
  
              else:
                  temp_buffer = image_data.reshape(height, width, 3)
  
              i, j, h, w = get_crop_c(height, width, scale, ratio)
  
              resize_crop_c(
                  temp_buffer, i, i + h, j, j + w, destination[dst_ix]
              )
  
          return destination[: len(batch_indices)]
  
      decode.is_parallel = True
      return decode
  
imports: from abc import ABCMeta, abstractmethod
  from dataclasses import replace
  from typing import Optional, Callable, TYPE_CHECKING, Tuple, Type
  import cv2
  import numpy
  from numba.typed import Dict
  from PIL.Image import Image
  from .base import Field, ARG_TYPE
  from ..pipeline.operation import Operation
  from ..pipeline.state import State
  from ..pipeline.compiler import Compiler
  from ..pipeline.allocation_query import AllocationQuery
  from ..libffcv import imdecode, memcpy, resize_crop
label_desc: Use image node_id 3 for calling the ResizedCropRGBImageDecoder obj's underlying member method code with example usage: obj.generate_code() and returns: decode, destination