code: def create_rand_tensor(
      opts, device: Optional[str] = "cpu", batch_size: Optional[int] = 1
  ) -> Tensor:
      sampler = getattr(opts, "sampler.name", "batch_sampler")
      if sampler.lower().find("video") > -1:
          video_stack = getattr(
              opts, "video_reader.frame_stack_format", "channel_first"
          )
          im_h, im_w, n_frames = video_size_from_opts(opts=opts)
          if video_stack == "channel_first":
              inp_tensor = torch.randint(
                  low=0,
                  high=255,
                  size=(
                      batch_size,
                      DEFAULT_IMAGE_CHANNELS,
                      n_frames,
                      im_h,
                      im_w,
                  ),
                  device=device,
              )
          else:
              inp_tensor = torch.randint(
                  low=0,
                  high=255,
                  size=(
                      batch_size,
                      n_frames,
                      DEFAULT_IMAGE_CHANNELS,
                      im_h,
                      im_w,
                  ),
                  device=device,
              )
      else:
          im_h, im_w = image_size_from_opts(opts=opts)
          inp_tensor = torch.randint(
              low=0,
              high=255,
              size=(batch_size, DEFAULT_IMAGE_CHANNELS, im_h, im_w),
              device=device,
          )
      inp_tensor = inp_tensor.float().div(255.0)
      return inp_tensor
  
file_path: ml-cvnets/utils/tensor_utils.py
imports: from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from torch import distributed
  from common import DEFAULT_IMAGE_CHANNELS, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, DEFAULT_VIDEO_FRAMES
  from utils.third_party.ddp_functional_utils import all_gather
label_desc: Use image node_id 3 for calling a global function with example usage: create_rand_tensor(opts, device, batch_size) and returns: inp_tensor