code: def launch_kernel(
      kernel, tensor_dims_map, full_grid, grid_blocks=None
  ):
      # cuda_max_grid = (2 ** 31 - 1, 2 ** 16 - 1, 2 ** 16 - 1)
      cuda_max_grid = (2147483647, 65535, 65535)[::-1]
      if grid_blocks is None:
          grid_blocks = cuda_max_grid
      else:
  
          def valid_grid_dim(g, mg):
              if g is None:
                  return mg
              else:
                  # grid must be at least 1 and no greater than mg
                  return max(1, min(g, mg))
  
          grid_blocks = tuple(
              valid_grid_dim(g, mg)
              for g, mg in zip(grid_blocks, cuda_max_grid)
          )  # type: ignore[assignment]
  
      for grid, *sliced_tensors in grid_partitioner(
          full_grid, grid_blocks, tensor_dims_map
      ):
          kernel(grid, *sliced_tensors)
  
imports: import math
  import os
  import torch
  import weakref
  from functools import lru_cache
  from torch.utils._triton import has_triton
  from ._triton_ops_meta import get_meta
  from typing import Optional, Tuple
label_desc: Use image node_id 13 for calling a global function with example usage: launch_kernel(kernel, tensor_dims_map, full_grid, grid_blocks) and returns: mg, max