code: def _adapted_sampling(
      shape: Union[Tuple[int, ...], torch.Size],
      dist: torch.distributions.Distribution,
      same_on_batch: Optional[bool] = False,
  ) -> Tensor:
      r"""The uniform sampling function that accepts 'same_on_batch'.
  
      If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]). By default,
      same_on_batch is set to False.
      """
      if isinstance(shape, tuple):
          shape = torch.Size(shape)
  
      if same_on_batch:
          return dist.sample(torch.Size((1, *shape[1:]))).repeat(
              shape[0], *[1] * (len(shape) - 1)
          )
      return dist.sample(shape)
  
imports: from functools import wraps
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch.distributions import Beta, Uniform
  from kornia.core import Tensor, as_tensor
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.keypoints import Keypoints
  from kornia.utils import _extract_device_dtype
label_desc: Use image node_id 12 for calling a global function with example usage: _adapted_sampling(shape, dist, same_on_batch) and returns: dist, dist