code: def get_rounding_func(
      rounding_func: Optional[Callable[[Tensor], Tensor]]
  ) -> Optional[Callable[[Tensor], Tensor]]:
      if rounding_func is None:
          botorch_rounding_func = rounding_func
      else:
          # make sure rounding_func is properly applied to q- and t-batches
          def botorch_rounding_func(X: Tensor) -> Tensor:
              batch_shape, d = X.shape[:-1], X.shape[-1]
              X_round = torch.stack(
                  [
                      rounding_func(x) for x in X.view(-1, d)
                  ]  # pyre-ignore: [16]
              )
              return X_round.view(*batch_shape, d)
  
      return botorch_rounding_func
  
imports: from __future__ import annotations
  import warnings
  from copy import deepcopy
  from logging import Logger
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from ax.core.search_space import SearchSpaceDigest
  from ax.core.types import TCandidateMetadata
  from ax.exceptions.core import DataRequiredError
  from ax.models.torch.botorch_defaults import get_and_fit_model, get_qLogNEI, recommend_best_observed_point, scipy_optimizer, TAcqfConstructor
  from ax.models.torch.utils import _datasets_to_legacy_inputs, _get_X_pending_and_observed, _to_inequality_constraints, normalize_indices, predict_from_model, subset_model
  from ax.models.torch_base import TorchGenResults, TorchModel, TorchOptConfig
  from ax.models.types import TConfig
  from ax.utils.common.constants import Keys
  from ax.utils.common.docutils import copy_doc
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast
  from botorch.acquisition.acquisition import AcquisitionFunction
  from botorch.models import ModelList
  from botorch.models.model import Model
  from botorch.utils.datasets import SupervisedDataset
  from botorch.utils.transforms import is_ensemble
  from torch import Tensor
  from torch.nn import ModuleList
label_desc: Use image node_id 1 for calling a global function with example usage: get_rounding_func(rounding_func) and returns: botorch_rounding_func, X_round