code: def standardize(Y: Tensor) -> Tensor:
      r"""Standardizes (zero mean, unit variance) a tensor by dim=-2.
  
      If the tensor is single-dimensional, simply standardizes the tensor.
      If for some batch index all elements are equal (or if there is only a single
      data point), this function will return 0 for that batch index.
  
      Args:
          Y: A `batch_shape x n x m`-dim tensor.
  
      Returns:
          The standardized `Y`.
  
      Example:
          >>> Y = torch.rand(4, 3)
          >>> Y_standardized = standardize(Y)
      """
      stddim = -1 if Y.dim() < 2 else -2
      Y_std = Y.std(dim=stddim, keepdim=True)
      Y_std = Y_std.where(Y_std >= 1e-9, torch.full_like(Y_std, 1.0))
      return (Y - Y.mean(dim=stddim, keepdim=True)) / Y_std
  
file_path: botorch/botorch/utils/transforms.py
imports: from __future__ import annotations
  import warnings
  from functools import wraps
  from typing import Any, Callable, List, Optional, TYPE_CHECKING
  import torch
  from botorch.utils.safe_math import logmeanexp
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: standardize(Y) and returns: unknown