class_docstr: Interface for torch models.
class_docstr_tok: ["Interface","for","torch","models","."]
docstr: Reshape input into model expected input.
  
  Parameters
  ----------
  x: np.ndarray
       A given input that is shaped.
  shape: Tuple[int...]
      The shape of the input.
  channel_first: boolean, optional
      Indicates of the image dimensions are channel first, or channel last.
      Inferred from the input shape if None.
  batched: boolean
      Indicates if the first dimension should be expanded or not, if it is just a single instance.
  
  Returns
  -------
  np.ndarray
      A reshaped input.
docstr_tok: ["Reshape","input","into","model","expected","input",".","Parameters","--","--","--","--","--","x",":","np.ndarray","A","given","input","that","is","shaped",".","shape",":","Tuple","[","int","...","]","The","shape","of","the","input",".","channel_first",":","boolean",",","optional","Indicates","of","the","image","dimensions","are","channel","first",",","or","channel","last",".","Inferred","from","the","input","shape","if","None",".","batched",":","boolean","Indicates","if","the","first","dimension","should","be","expanded","or","not",",","if","it","is","just","a","single","instance",".","Returns","--","--","--","-","np.ndarray","A","reshaped","input","."]
code: def shape_input(
      self,
      x: np.array,
      shape: Tuple[int, ...],
      channel_first: Optional[bool] = None,
      batched: bool = False,
  ) -> np.array:
      """
      Reshape input into model expected input.
  
      Parameters
      ----------
      x: np.ndarray
           A given input that is shaped.
      shape: Tuple[int...]
          The shape of the input.
      channel_first: boolean, optional
          Indicates of the image dimensions are channel first, or channel last.
          Inferred from the input shape if None.
      batched: boolean
          Indicates if the first dimension should be expanded or not, if it is just a single instance.
  
      Returns
      -------
      np.ndarray
          A reshaped input.
      """
      if channel_first is None:
          channel_first = utils.infer_channel_first(x)
  
      # Expand first dimension if this is just a single instance.
      if not batched:
          x = x.reshape(1, *shape)
  
      # Set channel order according to expected input of model.
      if self.channel_first:
          return utils.make_channel_first(x, channel_first)
      raise ValueError(
          "Channel first order expected for a torch model."
      )
  
imports: import copy
  from contextlib import suppress
  from copy import deepcopy
  from typing import Any, Dict, Optional, Tuple, List, Union, Generator
  import warnings
  import logging
  import numpy
  import torch
  from torch import nn
  from functools import lru_cache
  from quantus.helpers import utils
  from quantus.helpers.model.model_interface import ModelInterface
label_desc: Use image node_id 6 for calling the PyTorchModel obj's underlying member method code with example usage: obj.shape_input(x, shape, channel_first, batched) and returns: utils