code: def randomize_tensor_inplace(
      tensor: torch.Tensor, start=None, end=None
  ):
      """
      Randomize the target tensor according to the given range.
      """
      assert isinstance(tensor, torch.Tensor)
      if start is None and end is None:
          start, end = tensor.min(), tensor.max()
      assert start is not None and end is not None
      if tensor.dtype in torch_integer_dtype:
          # integer tensor can only be randomized by the torch.randint
          torch.randint(
              int(start),
              int(end + 1),
              tensor.size(),
              out=tensor.data,
              dtype=tensor.dtype,
          )
      else:
          # we can use nn.init.uniform_ to randomize this tensor
          # Note: the tensor that with integer type cannot be randomize
          # with nn.init.uniform_
          torch.nn.init.uniform_(tensor.data, start, end)
  
file_path: nni/nni/compression/speedup/utils.py
imports: from copy import deepcopy
  import logging
  from typing import Any, Dict, List, Tuple
  import torch
  from torch.fx.immutable_collections import immutable_dict, immutable_list
  from torch.utils._pytree import tree_map, tree_flatten, tree_unflatten, _register_pytree_node, Context
label_desc: Use image node_id 5 for calling a global function with example usage: randomize_tensor_inplace(tensor, start, end) without return types