class_docstr: Computes how often targets are in the top `K` predictions.
  
  Args:
      k: (Optional) Number of top elements to look at for computing accuracy.
          Defaults to `5`.
      name: (Optional) string name of the metric instance.
      dtype: (Optional) data type of the metric result.
  
  Standalone usage:
  
  >>> m = keras.metrics.TopKCategoricalAccuracy(k=1)
  >>> m.update_state([[0, 0, 1], [0, 1, 0]],
  ...                [[0.1, 0.9, 0.8], [0.05, 0.95, 0]])
  >>> m.result()
  0.5
  
  >>> m.reset_state()
  >>> m.update_state([[0, 0, 1], [0, 1, 0]],
  ...                [[0.1, 0.9, 0.8], [0.05, 0.95, 0]],
  ...                sample_weight=[0.7, 0.3])
  >>> m.result()
  0.3
  
  Usage with `compile()` API:
  
  ```python
  model.compile(optimizer='sgd',
                loss='categorical_crossentropy',
                metrics=[keras.metrics.TopKCategoricalAccuracy()])
  ```
class_docstr_tok: ["Computes","how","often","targets","are","in","the","top","`","K","`","predictions",".","Args",":","k",":","(","Optional",")","Number","of","top","elements","to","look","at","for","computing","accuracy",".","Defaults","to","`","5","`",".","name",":","(","Optional",")","string","name","of","the","metric","instance",".","dtype",":","(","Optional",")","data","type","of","the","metric","result",".","Standalone","usage",":",">",">",">","m","=","keras.metrics.TopKCategoricalAccuracy","(","k=1",")",">",">",">","m.update_state","(","[","[","0",",","0",",","1","]",",","[","0",",","1",",","0","]","]",",","...","[","[","0.1",",","0.9",",","0.8","]",",","[","0.05",",","0.95",",","0","]","]",")",">",">",">","m.result","(",")","0.5",">",">",">","m.reset_state","(",")",">",">",">","m.update_state","(","[","[","0",",","0",",","1","]",",","[","0",",","1",",","0","]","]",",","...","[","[","0.1",",","0.9",",","0.8","]",",","[","0.05",",","0.95",",","0","]","]",",","...","sample_weight=","[","0.7",",","0.3","]",")",">",">",">","m.result","(",")","0.3","Usage","with","`","compile","(",")","`","API",":","``","`","python","model.compile","(","optimizer='sgd","'",",","loss='categorical_crossentropy","'",",","metrics=","[","keras.metrics.TopKCategoricalAccuracy","(",")","]",")","``","`"]
code: def get_config(self):
      return {"name": self.name, "dtype": self.dtype, "k": self.k}
  
imports: from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.losses.loss import squeeze_to_same_rank
  from keras.metrics import reduction_metrics
label_desc: Use image node_id 2 for calling the TopKCategoricalAccuracy obj's underlying member method code with example usage: obj.get_config() and returns: dict