code: def get_token(src: str, magic: str) -> str:
      """Return randomly generated token to mask IPython magic with.
  
      For example, if 'magic' was `%matplotlib inline`, then a possible
      token to mask it with would be `"43fdd17f7e5ddc83"`. The token
      will be the same length as the magic, and we make sure that it was
      not already present anywhere else in the cell.
      """
      assert magic
      nbytes = max(len(magic) // 2 - 1, 1)
      token = TOKEN_HEX(nbytes)
      counter = 0
      while token in src:
          token = TOKEN_HEX(nbytes)
          counter += 1
          if counter > 100:
              raise AssertionError(
                  "INTERNAL ERROR: Black was not able to replace IPython magic. "
                  "Please report a bug on https://github.com/psf/black/issues.  "
                  f"The magic might be helpful: {magic}"
              ) from None
      if len(token) + 2 < len(magic):
          token = f"{token}."
      return f'"{token}"'
  
imports: import ast
  import collections
  import dataclasses
  import secrets
  import sys
  from functools import lru_cache
  from importlib.util import find_spec
  from typing import Dict, List, Optional, Tuple
  from black.output import out
  from black.report import NothingChanged
label_desc: Use image node_id 5 for calling a global function with example usage: get_token(src, magic) and returns: str, token, str