code: def _final_tuning(self, data):
      if self.dtype_dict[self.target] in (
          dtype.integer,
          dtype.float,
          dtype.quantity,
      ):
          self.model = self.model.eval()
          with torch.no_grad():
              acc_dict = {}
              for decode_log in [True, False]:
                  self.target_encoder.decode_log = decode_log
                  decoded_predictions = []
                  decoded_real_values = []
                  for X, Y in data:
                      X = X.to(self.model.device)
                      Y = Y.to(self.model.device)
                      Yh = self._net_call(X)
  
                      Yh = (
                          torch.unsqueeze(Yh, 0)
                          if len(Yh.shape) < 2
                          else Yh
                      )
                      Y = (
                          torch.unsqueeze(Y, 0)
                          if len(Y.shape) < 2
                          else Y
                      )
  
                      decoded_predictions.extend(
                          self.target_encoder.decode(Yh)
                      )
                      decoded_real_values.extend(
                          self.target_encoder.decode(Y)
                      )
  
                  acc_dict[decode_log] = r2_score(
                      decoded_real_values, decoded_predictions
                  )
  
          self.target_encoder.decode_log = (
              acc_dict[True] > acc_dict[False]
          )
  
imports: import time
  from copy import deepcopy
  from collections import deque
  from typing import Dict, List, Optional
  import torch
  import numpy
  import pandas
  from torch import nn
  import torch_optimizer
  from sklearn.metrics import r2_score
  from torch.cuda.amp import GradScaler
  from torch.utils.data import DataLoader
  from torch.nn.modules.loss import MSELoss
  from torch.optim.optimizer import Optimizer
  from type_infer.dtype import dtype
  from lightwood.helpers.log import log
  from lightwood.encoder.base import BaseEncoder
  from lightwood.helpers.torch import LightwoodAutocast
  from lightwood.data.encoded_ds import EncodedDs
  from lightwood.mixer.base import BaseMixer
  from lightwood.mixer.helpers.ar_net import ArNet
  from lightwood.mixer.helpers.default_net import DefaultNet
  from lightwood.api.types import PredictionArguments
  from lightwood.mixer.helpers.transform_corss_entropy_loss import TransformCrossEntropyLoss
label_desc: Use image node_id 2 for calling the Neural obj's underlying member method code with example usage: obj._final_tuning(data) without return types