code: def convert_from_huggingface(
      weights: Dict[str, Tensor],
      model: Transformer,
      n_heads: int,
      n_kv_heads: int,
  ):
      def permute(v: Tensor, n_heads: int):
          return (
              v.reshape(
                  n_heads, 2, v.shape[0] // n_heads // 2, v.shape[1]
              )
              .transpose(1, 2)
              .reshape(*v.shape[:2])
          )
  
      keymap = {
          "model.embed_tokens.weight": "tok_embeddings.weight",
          **{
              f"model.layers.{l}.input_layernorm.weight": f"layers.{l}.attention_norm.weight"
              for l in range(len(model.layers))
          },
          **{
              f"model.layers.{l}.self_attn.{x}_proj.weight": f"layers.{l}.attention.w{x}.weight"
              for x in ["q", "k", "v", "o"]
              for l in range(len(model.layers))
          },
          **{
              f"model.layers.{l}.post_attention_layernorm.weight": f"layers.{l}.ffn_norm.weight"
              for l in range(len(model.layers))
          },
          **{
              f"model.layers.{l}.mlp.{x}_proj.weight": f"layers.{l}.feed_forward.w{y}.weight"
              for x, y in {"gate": "1", "down": "2", "up": "3"}.items()
              for l in range(len(model.layers))
          },
          "model.norm.weight": "norm.weight",
          "lm_head.weight": "output.weight",
      }
      sd = {}
      for k, v in weights.items():
          if ".rotary_emb." in k:
              continue
          v = v.to(Device.DEFAULT)
          if "model.layers" in k:
              if "q_proj" in k:
                  v = permute(v, n_heads)
              elif "k_proj" in k:
                  v = permute(v, n_kv_heads)
          sd[keymap[k]] = v
      return sd
  
imports: from typing import Tuple, Union, Optional, Dict
  from tinygrad import Tensor, Variable, TinyJit, dtypes, nn, Device
  from tinygrad.helpers import getenv
label_desc: Use image node_id 5 for calling a global function with example usage: convert_from_huggingface(weights, model, n_heads, n_kv_heads) and returns: sd, v