code: def test_standardize(self):
      for dtype in (torch.float, torch.double):
          # basic init
          stdz = InputStandardize(d=2)
          self.assertTrue(stdz.training)
          self.assertEqual(stdz._d, 2)
          self.assertEqual(stdz.means.shape, torch.Size([1, 2]))
          self.assertEqual(stdz.stds.shape, torch.Size([1, 2]))
          stdz = InputStandardize(d=2, batch_shape=torch.Size([3]))
          self.assertTrue(stdz.training)
          self.assertEqual(stdz._d, 2)
          self.assertEqual(stdz.means.shape, torch.Size([3, 1, 2]))
          self.assertEqual(stdz.stds.shape, torch.Size([3, 1, 2]))
  
          # basic init, provided indices
          with self.assertRaises(ValueError):
              stdz = InputStandardize(d=2, indices=[0, 1, 2])
          with self.assertRaises(ValueError):
              stdz = InputStandardize(d=2, indices=[0, 2])
          with self.assertRaises(ValueError):
              stdz = InputStandardize(d=2, indices=[0, 0])
          with self.assertRaises(ValueError):
              stdz = InputStandardize(d=2, indices=[])
          stdz = InputStandardize(d=2, indices=[0])
          self.assertTrue(stdz.training)
          self.assertEqual(stdz._d, 2)
          self.assertEqual(stdz.means.shape, torch.Size([1, 1]))
          self.assertEqual(stdz.stds.shape, torch.Size([1, 1]))
          self.assertEqual(len(stdz.indices), 1)
          stdz.to(device=self.device)
          self.assertTrue(
              torch.equal(
                  stdz.indices,
                  torch.tensor(
                      [0], dtype=torch.long, device=self.device
                  ),
              )
          )
          stdz = InputStandardize(
              d=2, indices=[0], batch_shape=torch.Size([3])
          )
          stdz.to(device=self.device)
          self.assertTrue(stdz.training)
          self.assertEqual(stdz._d, 2)
          self.assertEqual(stdz.means.shape, torch.Size([3, 1, 1]))
          self.assertEqual(stdz.stds.shape, torch.Size([3, 1, 1]))
          self.assertEqual(len(stdz.indices), 1)
          self.assertTrue(
              torch.equal(
                  stdz.indices,
                  torch.tensor(
                      [0], device=self.device, dtype=torch.long
                  ),
              )
          )
  
          # test jitter
          stdz = InputStandardize(d=2, min_std=1e-4)
          self.assertEqual(stdz.min_std, 1e-4)
          X = torch.cat((torch.randn(4, 1), torch.zeros(4, 1)), dim=-1)
          X = X.to(self.device, dtype=dtype)
          self.assertEqual(torch.isfinite(stdz(X)).sum(), X.numel())
          with self.assertRaisesRegex(
              ValueError, r"must have at least \d+ dim"
          ):
              stdz(torch.randn(X.shape[-1], dtype=dtype))
  
          # basic usage
          for batch_shape in (torch.Size(), torch.Size([3])):
              stdz = InputStandardize(d=2, batch_shape=batch_shape)
              torch.manual_seed(42)
              X = torch.randn(
                  *batch_shape, 4, 2, device=self.device, dtype=dtype
              )
              for _X in (
                  torch.stack((X, X)),
                  X,
              ):  # check batch_shape is obeyed
                  X_stdz = stdz(_X)
                  self.assertEqual(
                      stdz.means.shape, batch_shape + (1, X.shape[-1])
                  )
                  self.assertEqual(
                      stdz.stds.shape, batch_shape + (1, X.shape[-1])
                  )
  
              self.assertTrue(
                  torch.all(X_stdz.mean(dim=-2).abs() < 1e-4)
              )
              self.assertTrue(
                  torch.all((X_stdz.std(dim=-2) - 1.0).abs() < 1e-4)
              )
  
              stdz.eval()
              X_unstdz = stdz.untransform(X_stdz)
              self.assertAllClose(X, X_unstdz, atol=1e-4, rtol=1e-4)
              expected_means = X.mean(dim=-2, keepdim=True)
              expected_stds = X.std(dim=-2, keepdim=True)
              self.assertAllClose(stdz.means, expected_means)
              self.assertAllClose(stdz.stds, expected_stds)
  
              # test to
              other_dtype = (
                  torch.float if dtype == torch.double else torch.double
              )
              stdz.to(other_dtype)
              self.assertTrue(stdz.means.dtype == other_dtype)
  
              # test errors on wrong shape
              stdz = InputStandardize(d=2, batch_shape=batch_shape)
              X = torch.randn(
                  *batch_shape, 2, 1, device=self.device, dtype=dtype
              )
              with self.assertRaises(BotorchTensorDimensionError):
                  stdz(X)
  
              # test no normalization on eval
              stdz = InputStandardize(
                  d=2, batch_shape=batch_shape, transform_on_eval=False
              )
              X = torch.randn(
                  *batch_shape, 4, 2, device=self.device, dtype=dtype
              )
              X_stdz = stdz(X)
              X_unstdz = stdz.untransform(X_stdz)
              self.assertAllClose(X, X_unstdz, atol=1e-4, rtol=1e-4)
              stdz.eval()
              self.assertTrue(torch.equal(stdz(X), X))
  
              # test no normalization on train
              stdz = InputStandardize(
                  d=2, batch_shape=batch_shape, transform_on_train=False
              )
              X_stdz = stdz(X)
              self.assertTrue(torch.equal(stdz(X), X))
              stdz.eval()
              X_unstdz = stdz.untransform(X_stdz)
              self.assertAllClose(X, X_unstdz, atol=1e-4, rtol=1e-4)
  
              # test indices
              indices = [0, 2]
              stdz = InputStandardize(
                  d=3, batch_shape=batch_shape, indices=indices
              )
              X = torch.randn(
                  *batch_shape, 4, 3, device=self.device, dtype=dtype
              )
              X_stdz = stdz(X)
              self.assertTrue(
                  torch.all(
                      X_stdz[..., indices].mean(dim=-2).abs() < 1e-4
                  )
              )
              self.assertTrue(
                  torch.all(
                      X_stdz[..., indices].std(dim=-2) < 1.0 + 1e-4
                  )
              )
              self.assertTrue(
                  torch.all(
                      (X_stdz[..., indices].std(dim=-2) - 1.0).abs()
                      < 1e-4
                  )
              )
              self.assertAllClose(X_stdz[..., 1], X[..., 1])
              stdz.eval()
              X_unstdz = stdz.untransform(X_stdz)
              self.assertAllClose(X, X_unstdz, atol=1e-4, rtol=1e-4)
  
              # test equals
              stdz = InputStandardize(
                  d=2, batch_shape=batch_shape, reverse=True
              )
              stdz2 = InputStandardize(
                  d=2, batch_shape=batch_shape, reverse=False
              )
              self.assertFalse(stdz.equals(stdz2))
              stdz3 = InputStandardize(
                  d=2, batch_shape=batch_shape, reverse=True
              )
              self.assertTrue(stdz.equals(stdz3))
              stdz4 = InputStandardize(
                  d=2, batch_shape=batch_shape, indices=[0, 1]
              )
              self.assertFalse(stdz4.equals(stdz))
              stdz5 = InputStandardize(
                  d=2, batch_shape=batch_shape, indices=[0]
              )
              self.assertFalse(stdz5.equals(stdz))
              stdz6 = InputStandardize(
                  d=2, batch_shape=batch_shape, indices=[0, 1]
              )
              self.assertTrue(stdz6.equals(stdz4))
              stdz7 = InputStandardize(
                  d=3, batch_shape=batch_shape, indices=[0, 1]
              )
              stdz8 = InputStandardize(
                  d=3, batch_shape=batch_shape, indices=[0, 2]
              )
              self.assertFalse(stdz7.equals(stdz8))
  
imports: import itertools
  import warnings
  from copy import deepcopy
  from random import randint
  import torch
  from botorch import settings
  from botorch.exceptions.errors import BotorchTensorDimensionError
  from botorch.exceptions.warnings import UserInputWarning
  from botorch.models.transforms.input import AffineInputTransform, AppendFeatures, ChainedInputTransform, FilterFeatures, InputPerturbation, InputStandardize, InputTransform, Log10, Normalize, OneHotToNumeric, Round, Warp
  from botorch.models.transforms.utils import expand_and_copy_tensor
  from botorch.models.utils import fantasize
  from botorch.utils.testing import BotorchTestCase
  from gpytorch.priors import LogNormalPrior
  from torch import Tensor
  from torch.distributions import Kumaraswamy
  from torch.nn import Module
  from torch.nn.functional import one_hot
label_desc: Use image node_id 3 for calling the TestInputTransforms obj's underlying member method code with example usage: obj.test_standardize() without return types