def METHOD_NAME(self, payload: Union[Dict, InferRequest], headers: Dict[str, str] = None) -> torch.Tensor:
    raw_img_data = None
    if isinstance(payload, Dict) and "instances" in payload:
        headers["request-type"] = "v1"
        if "data" in payload["instances"][0]:
            # assume the data is already preprocessed in transformer
            np_array = np.asarray(payload["instances"][0]["data"])
            input_tensor = torch.Tensor(np_array)
            return input_tensor.unsqueeze(0)
        elif "image" in payload["instances"][0]:
            # Input follows the Tensorflow V1 HTTP API for binary values
            # https://www.tensorflow.org/tfx/serving/api_rest#encoding_binary_values
            img_data = payload["instances"][0]["image"]["b64"]
            raw_img_data = base64.b64decode(img_data)
    elif isinstance(payload, InferRequest):
        infer_input = payload.inputs[0]
        if infer_input.datatype == "BYTES":
            if payload.from_grpc:
                raw_img_data = infer_input.data[0]
            else:
                raw_img_data = base64.b64decode(infer_input.data[0])
        elif infer_input.datatype == "FP32":
            # assume the data is already preprocessed in transformer
            input_np = infer_input.as_numpy()
            return torch.Tensor(input_np)
    else:
        raise InvalidInput("invalid payload")
    input_image = Image.open(io.BytesIO(raw_img_data))
    METHOD_NAME = transforms.Compose([
        transforms.Resize(256),
        transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.485, 0.456, 0.406],
                             std=[0.229, 0.224, 0.225]),
    ])
    input_tensor = METHOD_NAME(input_image)
    return input_tensor.unsqueeze(0)