class_docstr: Get parameters for ```crop``` transformation for crop transform.
  
  Args:
      size (tuple): Desired size of the crop operation, like (d, h, w).
          If tensor, it must be (B, 3).
      resize_to (tuple): Desired output size of the crop, like (d, h, w). If None, no resize will be performed.
  
  Returns:
      A dict of parameters to be passed for transformation.
          - src (Tensor): cropping bounding boxes with a shape of (B, 8, 3).
          - dst (Tensor): output bounding boxes with a shape (B, 8, 3).
  
  Note:
      The generated random numbers are not reproducible across different devices and dtypes. By default,
      the parameters will be generated on CPU in float32. This can be changed by calling
      ``self.set_rng_device_and_dtype(device="cuda", dtype=torch.float64)``.
class_docstr_tok: ["Get","parameters","for","``","`","crop","``","`","transformation","for","crop","transform",".","Args",":","size","(","tuple",")",":","Desired","size","of","the","crop","operation",",","like","(","d",",","h",",","w",")",".","If","tensor",",","it","must","be","(","B",",","3",")",".","resize_to","(","tuple",")",":","Desired","output","size","of","the","crop",",","like","(","d",",","h",",","w",")",".","If","None",",","no","resize","will","be","performed",".","Returns",":","A","dict","of","parameters","to","be","passed","for","transformation",".","-","src","(","Tensor",")",":","cropping","bounding","boxes","with","a","shape","of","(","B",",","8",",","3",")",".","-","dst","(","Tensor",")",":","output","bounding","boxes","with","a","shape","(","B",",","8",",","3",")",".","Note",":","The","generated","random","numbers","are","not","reproducible","across","different","devices","and","dtypes",".","By","default",",","the","parameters","will","be","generated","on","CPU","in","float32",".","This","can","be","changed","by","calling","``","self.set_rng_device_and_dtype","(","device=","''","cuda","''",",","dtype=torch.float64",")","``","."]
code: def forward(
      self, batch_shape: Tuple[int, ...], same_on_batch: bool = False
  ) -> Dict[str, Tensor]:
      batch_size, _, depth, height, width = batch_shape
      _common_param_check(batch_size, same_on_batch)
      _device, _dtype = _extract_device_dtype(
          [self.size if isinstance(self.size, Tensor) else None]
      )
  
      if not isinstance(self.size, Tensor):
          size = tensor(self.size, device=_device, dtype=_dtype).repeat(
              batch_size, 1
          )
      else:
          size = self.size.to(device=_device, dtype=_dtype)
      if size.shape != torch.Size([batch_size, 3]):
          raise AssertionError(
              "If `size` is a tensor, it must be shaped as (B, 3). "
              f"Got {size.shape} while expecting {torch.Size([batch_size, 3])}."
          )
      if not (
          isinstance(depth, (int,))
          and isinstance(height, (int,))
          and isinstance(width, (int,))
          and depth > 0
          and height > 0
          and width > 0
      ):
          raise AssertionError(
              f"`batch_shape` should not contain negative values. Got {(batch_shape)}."
          )
  
      x_diff = width - size[:, 2] + 1
      y_diff = height - size[:, 1] + 1
      z_diff = depth - size[:, 0] + 1
  
      if (x_diff < 0).any() or (y_diff < 0).any() or (z_diff < 0).any():
          raise ValueError(
              f"input_size {(depth, height, width)} cannot be smaller than crop size {size!s} in any dimension."
          )
  
      if batch_size == 0:
          return {
              "src": zeros([0, 8, 3], device=_device, dtype=_dtype),
              "dst": zeros([0, 8, 3], device=_device, dtype=_dtype),
          }
  
      x_start = _adapted_rsampling(
          (batch_size,), self.rand_sampler, same_on_batch
      ).to(device=_device, dtype=_dtype)
      y_start = _adapted_rsampling(
          (batch_size,), self.rand_sampler, same_on_batch
      ).to(device=_device, dtype=_dtype)
      z_start = _adapted_rsampling(
          (batch_size,), self.rand_sampler, same_on_batch
      ).to(device=_device, dtype=_dtype)
  
      x_start = (x_start * x_diff).floor()
      y_start = (y_start * y_diff).floor()
      z_start = (z_start * z_diff).floor()
  
      crop_src = bbox_generator3d(
          x_start.view(-1),
          y_start.view(-1),
          z_start.view(-1),
          size[:, 2] - 1,
          size[:, 1] - 1,
          size[:, 0] - 1,
      )
  
      if self.resize_to is None:
          crop_dst = bbox_generator3d(
              tensor([0] * batch_size, device=_device, dtype=_dtype),
              tensor([0] * batch_size, device=_device, dtype=_dtype),
              tensor([0] * batch_size, device=_device, dtype=_dtype),
              size[:, 2] - 1,
              size[:, 1] - 1,
              size[:, 0] - 1,
          )
      else:
          if not (
              len(self.resize_to) == 3
              and isinstance(self.resize_to[0], (int,))
              and isinstance(self.resize_to[1], (int,))
              and isinstance(self.resize_to[2], (int,))
              and self.resize_to[0] > 0
              and self.resize_to[1] > 0
              and self.resize_to[2] > 0
          ):
              raise AssertionError(
                  f"`resize_to` must be a tuple of 3 positive integers. Got {self.resize_to}."
              )
          crop_dst = tensor(
              [
                  [
                      [0, 0, 0],
                      [self.resize_to[-1] - 1, 0, 0],
                      [
                          self.resize_to[-1] - 1,
                          self.resize_to[-2] - 1,
                          0,
                      ],
                      [0, self.resize_to[-2] - 1, 0],
                      [0, 0, self.resize_to[-3] - 1],
                      [
                          self.resize_to[-1] - 1,
                          0,
                          self.resize_to[-3] - 1,
                      ],
                      [
                          self.resize_to[-1] - 1,
                          self.resize_to[-2] - 1,
                          self.resize_to[-3] - 1,
                      ],
                      [
                          0,
                          self.resize_to[-2] - 1,
                          self.resize_to[-3] - 1,
                      ],
                  ]
              ],
              device=_device,
              dtype=_dtype,
          ).repeat(batch_size, 1, 1)
  
      return {
          "src": crop_src.to(device=_device),
          "dst": crop_dst.to(device=_device),
      }
  
file_path: kornia/kornia/augmentation/random_generator/_3d/crop.py
imports: from typing import Dict, Optional, Tuple, Union
  import torch
  from torch.distributions import Uniform
  from kornia.augmentation.random_generator.base import RandomGeneratorBase
  from kornia.augmentation.utils import _adapted_rsampling, _common_param_check
  from kornia.core import Device, Tensor, tensor, zeros
  from kornia.geometry.bbox import bbox_generator3d
  from kornia.utils.helpers import _extract_device_dtype
label_desc: Use image node_id 4 for calling the CropGenerator3D obj's underlying member method code with example usage: obj.forward(batch_shape, same_on_batch) and returns: dict, dict