code: def random_2d_perlin(
      shape: tuple,
      res: tuple[int | Tensor, int | Tensor],
      fade=lambda t: 6 * t**5 - 15 * t**4 + 10 * t**3,
  ) -> np.ndarray | Tensor:
      """Returns a random 2d perlin noise array.
  
      Args:
          shape (tuple): Shape of the 2d map.
          res (tuple[int | Tensor, int | Tensor]): Tuple of scales for perlin noise for height and width dimension.
          fade (_type_, optional): Function used for fading the resulting 2d map.
              Defaults to equation 6*t**5-15*t**4+10*t**3.
  
      Returns:
          np.ndarray | Tensor: Random 2d-array/tensor generated using perlin noise.
      """
      if isinstance(res[0], int):
          result = _rand_perlin_2d_np(shape, res, fade)
      elif isinstance(res[0], Tensor):
          result = _rand_perlin_2d(shape, res, fade)
      else:
          raise TypeError(f"got scales of type {type(res[0])}")
      return result
  
file_path: anomalib/src/anomalib/data/utils/generators/perlin.py
imports: from __future__ import annotations
  import math
  import numpy
  import torch
  from torch import Tensor
label_desc: Use image node_id 4 for calling a global function with example usage: random_2d_perlin(shape, res, fade) and returns: result