code: def _pytorch_fashion_inference(
      model, input_data, batch_size=None, output_tensor=True
  ):
      """
      This is an internal inference pattern for any models which can be used like:
      `model(x)  # x is a pytorch tensor`
  
      :param model: The model to inference
      :param input_data: numpy ndarray
      :param batch_size: batch size
      :param output_tensor: whether original output of the model is Tensor.
  
      :return: numpy ndarray
      """
      if output_tensor:
          if isinstance(input_data, list):
              input_sample_list = list(
                  map(lambda x: torch.from_numpy(x), input_data)
              )
          elif isinstance(input_data, DataLoader):
              input_sample_list = [
                  torch.cat(
                      tuple(batch[0] for batch in input_data), dim=0
                  )
              ]
          else:
              input_sample_list = [torch.from_numpy(input_data)]
          yhat = _tensor_inference(
              model, input_sample_list, batch_size=batch_size
          )
      else:
          # Reduce time of type transforms between tensor and numpy
          if isinstance(input_data, DataLoader):
              input_sample = tuple(
                  batch[0].numpy() for batch in input_data
              )
              input_sample_list = [np.concatenate(input_sample, axis=0)]
          elif isinstance(input_data, np.ndarray):
              input_sample_list = [input_data]
          else:
              input_sample_list = input_data
          yhat = _numpy_inference(
              model, input_sample_list, batch_size=batch_size
          )
      return yhat
  
imports: import math
  import torch
  import numpy
  from torch.utils.data.dataloader import DataLoader
label_desc: Use image node_id 3 for calling a global function with example usage: _pytorch_fashion_inference(model, input_data, batch_size, output_tensor) and returns: yhat