code: def _reweight_bag(
      weighting: WeightingType,
      bag: dict[Any, int],
      doclike: types.DocLike,
  ) -> dict[Any, int] | dict[Any, float]:
      if weighting == "count":
          return bag
      elif weighting == "freq":
          n_tokens = len(doclike)
          return {
              term: weight / n_tokens for term, weight in bag.items()
          }
      elif weighting == "binary":
          return {term: 1 for term in bag.keys()}
      else:
          raise ValueError(
              errors.value_invalid_msg(
                  "weighting", weighting, {"count", "freq", "binary"}
              )
          )
  
file_path: textacy/src/textacy/extract/bags.py
imports: from __future__ import annotations
  import operator
  from typing import Any, Collection, Literal, Optional, Union
  import cytoolz
  from ..None import errors, types
  from .None import basics
label_desc: Use image node_id 3 for calling a global function with example usage: _reweight_bag(weighting, bag, doclike) and returns: bag, unknown, unknown