code: def subset_transform(transform):
      r"""Decorator of an input transform function to separate out indexing logic."""
  
      @wraps(transform)
      def f(self, X: Tensor) -> Tensor:
          if not hasattr(self, "indices") or self.indices is None:
              return transform(self, X)
          has_shape = hasattr(self, "batch_shape")
          Y = (
              expand_and_copy_tensor(X, self.batch_shape)
              if has_shape
              else X.clone()
          )
          Y[..., self.indices] = transform(self, X[..., self.indices])
          return Y
  
      return f
  
file_path: botorch/botorch/models/transforms/utils.py
imports: from __future__ import annotations
  from functools import wraps
  from typing import Tuple
  import torch
  from torch import Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: subset_transform(transform) and returns: f, Y, transform