class_docstr: This is a basic class which preprocesses the data.
  Basically, it takes messy data, detects potential nan, bad types end convert the
  data to a type handled by the VAE models (*i.e.* `torch.Tensor`). Moreover, if the
  data does not have the same shape, a reshaping is applied and data is resized to the
  **minimal shape**.
class_docstr_tok: ["This","is","a","basic","class","which","preprocesses","the","data",".","Basically",",","it","takes","messy","data",",","detects","potential","nan",",","bad","types","end","convert","the","data","to","a","type","handled","by","the","VAE","models","(","*","i.e",".","*","`","torch.Tensor","`",")",".","Moreover",",","if","the","data","does","not","have","the","same","shape",",","a","reshaping","is","applied","and","data","is","resized","to","the","*","*","minimal","shape","*","*","."]
docstr: Converts numpy arrays to `torch.Tensor` format
  
  Args:
      data (np.ndarray): The data to be converted
  
  Return:
      (torch.Tensor): The transformed data
docstr_tok: ["Converts","numpy","arrays","to","`","torch.Tensor","`","format","Args",":","data","(","np.ndarray",")",":","The","data","to","be","converted","Return",":","(","torch.Tensor",")",":","The","transformed","data"]
code: def to_tensor(data: np.ndarray) -> torch.Tensor:
      """Converts numpy arrays to `torch.Tensor` format
  
      Args:
          data (np.ndarray): The data to be converted
  
      Return:
          (torch.Tensor): The transformed data"""
  
      # check input type
      if not torch.is_tensor(data):
          if not isinstance(data, np.ndarray):
              raise TypeError(
                  " Data must be either of type "
                  f"< 'torch.Tensor' > or < 'np.ndarray' > ({type(data)} provided). "
                  f" Check data"
              )
  
          else:
              try:
                  data = torch.tensor(data).type(torch.float)
  
              except (TypeError, RuntimeError) as e:
                  raise TypeError(
                      str(e.args) + ". Potential issues:\n"
                      "- input data has not the same shape in array\n"
                      "- input data with unhandable type"
                  ) from e
  
      return data
  
file_path: benchmark_VAE/src/pythae/data/preprocessors.py
imports: import logging
  from typing import Optional, Union
  import numpy
  import torch
  from typing_extensions import Literal
  from pythae.data.datasets import BaseDataset
label_desc: Use image node_id 5 for calling the DataProcessor obj's underlying member method code with example usage: obj.to_tensor(data) and returns: data